<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=2"><meta name="theme-color" content="#FFF"><meta name="baidu-site-verification" content="code-DvHFUp3jdk"><meta name="baidu-site-verification" content="code-eHnRZZHAeP"><meta name="baidu-site-verification" content="code-EmlZBboqEW"><meta name="baidu-site-verification" content="code-Hf9ZXEHZ41"><meta name="360-site-verification" content="941073b91e9afaf02748ba000ba47e80"><meta name="360-site-verification" content="010bd45f0d523ce46f298dd597ef0289"><meta name="sogou_site_verification" content="hlLPNfmIjv"><meta name="sogou_site_verification" content="y3La2dTB20"><meta name="msvalidate.01" content="03829B28CC46A7AA4B5503897F475BA1"><script>!function(){var s="https://s.ssl.qhres2.com/ssl/ab77b6ea7f3fbf79.js";document.write('<script src="'+s+'" id="sozz"><\/script>')}()</script><script>!function(t,e,c,n,r,a,s){t[c]=t[c]||function(){(t[c].q=t[c].q||[]).push(arguments)},a=e.createElement(n),a.async=1,a.src="https://www.clarity.ms/tag/"+r+"?ref=bwt",s=e.getElementsByTagName(n)[0],s.parentNode.insertBefore(a,s)}(window,document,"clarity","script","8xwpfccwj2")</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?1d318b0509ca0909017253ed6f659ae4";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?aea6c1471d6299bdd1c87a0836f18675";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?498ca413655655a62058d6b5d7c62786";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?e19e8161e13f718806b79f49240583b4";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png"><link rel="icon" type="image/ico" sizes="32x32" href="/images/favicon.ico"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="google-site-verification" content="UA-139249935-1"><meta name="baidu-site-verification" content="cOtBu9CtTEIuwJeN"><link rel="alternate" type="application/rss+xml" title="了尘兰若的小坑" href="https://liaochenlanruo.gitee.io/rss.xml"><link rel="alternate" type="application/atom+xml" title="了尘兰若的小坑" href="https://liaochenlanruo.gitee.io/atom.xml"><link rel="alternate" type="application/json" title="了尘兰若的小坑" href="https://liaochenlanruo.gitee.io/feed.json"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Mulish:300,300italic,400,400italic,700,700italic%7CFredericka%20the%20Great:300,300italic,400,400italic,700,700italic%7CNoto%20Serif%20JP:300,300italic,400,400italic,700,700italic%7CNoto%20Serif%20SC:300,300italic,400,400italic,700,700italic%7CInconsolata:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext"><link rel="stylesheet" href="/css/app.css?v=0.2.5"><meta name="keywords" content="扩增子"><link rel="canonical" href="https://liaochenlanruo.gitee.io/post/4cf4.html"><title>Use microeco分析扩增子数据 - 生物信息 | ResearchGo = 了尘兰若的小坑 = liaochenlanruo</title><meta name="generator" content="Hexo 5.4.0"></head><body itemscope itemtype="http://schema.org/WebPage"><div id="loading"><div class="cat"><div class="body"></div><div class="head"><div class="face"></div></div><div class="foot"><div class="tummy-end"></div><div class="bottom"></div><div class="legs left"></div><div class="legs right"></div></div><div class="paw"><div class="hands left"></div><div class="hands right"></div></div></div></div><div id="container"><header id="header" itemscope itemtype="http://schema.org/WPHeader"><div class="inner"><div id="brand"><div class="pjax"><h1 itemprop="name headline">Use microeco分析扩增子数据</h1><div class="meta"><span class="item" title="Created: 2021-03-14 15:01:45"><span class="icon"><i class="ic i-calendar"></i> </span><span class="text">Posted on</span> <time itemprop="dateCreated datePublished" datetime="2021-03-14T15:01:45+08:00">2021-03-14</time> </span><span class="item" title="Symbols count in article"><span class="icon"><i class="ic i-pen"></i> </span><span class="text">Symbols count in article</span> <span>28k</span> <span class="text">words</span> </span><span class="item" title="Reading time"><span class="icon"><i class="ic i-clock"></i> </span><span class="text">Reading time</span> <span>26 mins.</span></span></div></div></div><nav id="nav"><div class="inner"><div class="toggle"><div class="lines" aria-label="Toggle navigation bar"><span class="line"></span> <span class="line"></span> <span class="line"></span></div></div><ul class="menu"><li class="item title"><a href="/" rel="start">ResearchGo</a></li></ul><ul class="right"><li class="item theme"><i class="ic i-sun"></i></li><li class="item search"><i class="ic i-search"></i></li></ul></div></nav></div><div id="imgs" class="pjax"><img src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/img/custom/bgs/thumb_68.webp"></div></header><div id="waves"><svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"/></defs><g class="parallax"><use xlink:href="#gentle-wave" x="48" y="0"/><use xlink:href="#gentle-wave" x="48" y="3"/><use xlink:href="#gentle-wave" x="48" y="5"/><use xlink:href="#gentle-wave" x="48" y="7"/></g></svg></div><main><div class="inner"><div id="main" class="pjax"><div class="article wrap"><div class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList"><i class="ic i-home"></i> <span><a href="/">Home</a></span><i class="ic i-angle-right"></i> <span class="current" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a href="/categories/Bioinformatics/" itemprop="item" rel="index" title="In 生物信息"><span itemprop="name">生物信息</span></a><meta itemprop="position" content="1"></span></div><article itemscope itemtype="http://schema.org/Article" class="post block" lang="en"><link itemprop="mainEntityOfPage" href="https://liaochenlanruo.gitee.io/post/4cf4.html"><span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="image" content="/images/head.jpg"><meta itemprop="name" content="Hualin Liu"><meta itemprop="description" content="liaochenlanruo, 分享微生物生物信息学分析方法，欢迎加入QQ群交流945751012，不接受群内广告！"></span><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="了尘兰若的小坑"></span><div class="body md" itemprop="articleBody"><div class="gallery" itemscope itemtype="http://schema.org/ImageGallery"><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/img/custom/bgs/thumb_68.webp" itemprop="contentUrl"></div><p>本文阐述使用 microeco 分析扩增子数据……</p><span id="more"></span><h1 id="font-colorff0000-1-安装microecofont"><a class="anchor" href="#font-colorff0000-1-安装microecofont">#</a> <font color="#FF0000">1. 安装 microeco</font></h1><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># If devtools package is not installed, first install it</span></pre></td></tr><tr><td data-num="2"></td><td><pre>install.packages<span class="token punctuation">(</span><span class="token string">"devtools"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># then install microeco</span></pre></td></tr><tr><td data-num="4"></td><td><pre>devtools<span class="token operator">::</span>install_github<span class="token punctuation">(</span><span class="token string">"ChiLiubio/microeco"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>requireNamespace<span class="token punctuation">(</span><span class="token string">"devtools"</span><span class="token punctuation">,</span> quietly <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span>install.packages<span class="token punctuation">(</span><span class="token string">"devtools"</span><span class="token punctuation">)</span><span class="token punctuation">&#125;</span></pre></td></tr><tr><td data-num="7"></td><td><pre>devtools<span class="token operator">::</span>install_github<span class="token punctuation">(</span><span class="token string">"jbisanz/qiime2R"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h1 id="font-colorff0000-2-准备数据font"><a class="anchor" href="#font-colorff0000-2-准备数据font">#</a> <font color="#FF0000">2. 准备数据</font></h1><h2 id="font-colorff9800-otu_tablefont"><a class="anchor" href="#font-colorff9800-otu_tablefont">#</a> <font color="#FF9800">otu_table</font></h2><p>OTU 表</p><table><thead><tr><th>Sample 1</th><th>Sample 2</th><th>Sample 3</th><th>Sample 4</th></tr></thead><tbody><tr><td>OTU1</td><td>232.0</td><td>209.0</td><td>349.0</td><td>256.0</td></tr><tr><td>OTU2</td><td>75.0</td><td>35.0</td><td>44.0</td><td>0.0</td></tr><tr><td>OTU3</td><td>237.0</td><td>224.0</td><td>291.0</td><td>353.0</td></tr><tr><td>OTU4</td><td>371.0</td><td>80.0</td><td>319.0</td><td>345.0</td></tr></tbody></table><h2 id="font-colorff9800-taxonomy_tablefont"><a class="anchor" href="#font-colorff9800-taxonomy_tablefont">#</a> <font color="#FF9800">taxonomy_table</font></h2><p>分类表</p><div style="overflow-x:auto"><table><table><thead><tr><th>Kingdom</th><th>Phylum</th><th>Class</th><th>Order</th><th>Family</th><th>Genus</th><th>Species</th></tr></thead><tbody><tr><td>OTU1</td><td>d__Bacteria</td><td>p__Desulfobacterota</td><td>c__Desulfobacteria</td><td>o__Desulfatiglandales</td><td>f__Desulfatiglandaceae</td><td colspan="2">g__Desulfatiglans</td></tr><tr><td>OTU2</td><td>d__Bacteria</td><td>p__Sva0485</td><td>c__Sva0485</td><td>o__Sva0485</td><td>f__Sva0485</td><td>g__Sva0485</td><td>s__uncultured_hydrocarbon</td></tr><tr><td>OTU3</td><td>d__Bacteria</td><td>p__Desulfobacterota</td><td>c__Syntrophobacteria</td><td>o__Syntrophobacterales</td><td>f__uncultured</td><td>g__uncultured</td><td>s__uncultured_delta</td></tr><tr><td>OTU4</td><td>d__Bacteria</td><td>p__Myxococcota</td><td>c__Polyangia</td><td>o__Polyangiales</td><td>f__Sandaracinaceae</td><td colspan="2">g__uncultured</td></tr></tbody></table></table></div><h2 id="font-colorff9800-sample_infofont"><a class="anchor" href="#font-colorff9800-sample_infofont">#</a> <font color="#FF9800">sample_info</font></h2><p>样本元数据</p><table><thead><tr><th>SampleID</th><th>Group</th><th>Type</th><th>Saline</th></tr></thead><tbody><tr><td>Sample 1</td><td>G1</td><td>T1</td><td>Non-saline</td></tr><tr><td>Sample 2</td><td>G1</td><td>T1</td><td>Non-saline</td></tr><tr><td>Sample 3</td><td>G2</td><td>T1</td><td>Saline</td></tr><tr><td>Sample 4</td><td>G2</td><td>T2</td><td>Saline</td></tr></tbody></table><h2 id="font-colorff9800-env_datafont"><a class="anchor" href="#font-colorff9800-env_datafont">#</a> <font color="#FF9800">env_data</font></h2><p>环境因子</p><table><thead><tr><th>SampleID</th><th>Depth</th><th>Longitude</th><th>Latitude</th></tr></thead><tbody><tr><td>Sample 1</td><td>0</td><td>23.0</td><td>20</td></tr><tr><td>Sample 2</td><td>10</td><td>35.0</td><td>44.0</td></tr><tr><td>Sample 3</td><td>20</td><td>43.0</td><td>70.0</td></tr><tr><td>Sample 4</td><td>30</td><td>60.0</td><td>69.0</td></tr></tbody></table><h2 id="font-colorff9800-phylo_treefont"><a class="anchor" href="#font-colorff9800-phylo_treefont">#</a> <font color="#FF9800">phylo_tree</font></h2><p>进化树</p><h1 id="font-colorff0000-3-导入数据font"><a class="anchor" href="#font-colorff0000-3-导入数据font">#</a> <font color="#FF0000">3. 导入数据</font></h1><ul><li><p>加载 R 包</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>library<span class="token punctuation">(</span>microeco<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>library<span class="token punctuation">(</span>ape<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>library<span class="token punctuation">(</span>qiime2R<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># use pipe operator in magrittr package</span></pre></td></tr><tr><td data-num="5"></td><td><pre>library<span class="token punctuation">(</span>magrittr<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># set.seed is used to fix the random number generation to make the results repeatable</span></pre></td></tr><tr><td data-num="7"></td><td><pre>set.seed<span class="token punctuation">(</span><span class="token number">123</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># make the plotting background same with the tutorial</span></pre></td></tr><tr><td data-num="9"></td><td><pre>library<span class="token punctuation">(</span>ggplot2<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre>theme_set<span class="token punctuation">(</span>theme_bw<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>导入数据</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 单独导入环境因子文件</span></pre></td></tr><tr><td data-num="2"></td><td><pre>  env_data <span class="token operator">&lt;-</span> read.delim<span class="token punctuation">(</span><span class="token string">"E:/Researches/lujia16S/Analysis_20200907/Ordination_analyses/env4.txt"</span><span class="token punctuation">,</span> sep <span class="token operator">=</span> <span class="token string">"\t"</span><span class="token punctuation">,</span> header <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> row.names <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre>  <span class="token comment"># 定义数据导入函数</span></pre></td></tr><tr><td data-num="5"></td><td><pre>  qiimed2meco <span class="token operator">&lt;-</span> <span class="token keyword">function</span><span class="token punctuation">(</span>ASV_data<span class="token punctuation">,</span> sample_data<span class="token punctuation">,</span> taxonomy_data<span class="token punctuation">,</span> phylo_tree <span class="token operator">=</span> <span class="token keyword">NULL</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span></pre></td></tr><tr><td data-num="6"></td><td><pre>  	<span class="token comment"># Read ASV data</span></pre></td></tr><tr><td data-num="7"></td><td><pre>  	ASV <span class="token operator">&lt;-</span> as.data.frame<span class="token punctuation">(</span>read_qza<span class="token punctuation">(</span>ASV_data<span class="token punctuation">)</span><span class="token operator">$</span>data<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre>  	<span class="token comment">#  Read metadata</span></pre></td></tr><tr><td data-num="9"></td><td><pre>  	metadata <span class="token operator">&lt;-</span> read_q2metadata<span class="token punctuation">(</span>sample_data<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre>  	rownames<span class="token punctuation">(</span>metadata<span class="token punctuation">)</span> <span class="token operator">&lt;-</span> as.character<span class="token punctuation">(</span>metadata<span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre>  	<span class="token comment"># Read taxonomy table</span></pre></td></tr><tr><td data-num="12"></td><td><pre>  	taxa_table <span class="token operator">&lt;-</span> read_qza<span class="token punctuation">(</span>taxonomy_data<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="13"></td><td><pre>  	taxa_table <span class="token operator">&lt;-</span> parse_taxonomy<span class="token punctuation">(</span>taxa_table<span class="token operator">$</span>data<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="14"></td><td><pre>  	<span class="token comment"># Make the taxonomic table clean, this is very important.</span></pre></td></tr><tr><td data-num="15"></td><td><pre>  	taxa_table <span class="token percent-operator operator">%&lt;>%</span> tidy_taxonomy</pre></td></tr><tr><td data-num="16"></td><td><pre>  	<span class="token comment"># Read phylo tree</span></pre></td></tr><tr><td data-num="17"></td><td><pre>  	<span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>is.null<span class="token punctuation">(</span>phylo_tree<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span></pre></td></tr><tr><td data-num="18"></td><td><pre>  		phylo_tree <span class="token operator">&lt;-</span> read_qza<span class="token punctuation">(</span>phylo_tree<span class="token punctuation">)</span><span class="token operator">$</span>data</pre></td></tr><tr><td data-num="19"></td><td><pre>  	<span class="token punctuation">&#125;</span></pre></td></tr><tr><td data-num="20"></td><td><pre>  	dataset <span class="token operator">&lt;-</span> microtable<span class="token operator">$</span>new<span class="token punctuation">(</span>sample_table <span class="token operator">=</span> metadata<span class="token punctuation">,</span> tax_table <span class="token operator">=</span> taxa_table<span class="token punctuation">,</span> otu_table <span class="token operator">=</span> ASV<span class="token punctuation">,</span> phylo_tree <span class="token operator">=</span> phylo_tree<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="21"></td><td><pre>  	dataset</pre></td></tr><tr><td data-num="22"></td><td><pre>  <span class="token punctuation">&#125;</span></pre></td></tr><tr><td data-num="23"></td><td><pre></pre></td></tr><tr><td data-num="24"></td><td><pre>  <span class="token comment"># 导入本地数据，包括 OTU 表、样本元数据、分类表、tree 文件。这几个文件均有 QIIME2 生成。</span></pre></td></tr><tr><td data-num="25"></td><td><pre>  meco_dataset <span class="token operator">&lt;-</span> qiimed2meco<span class="token punctuation">(</span>ASV_data <span class="token operator">=</span> <span class="token string">"E:/Researches/lujia16S/Analysis_20200907/dada2_table.qza"</span><span class="token punctuation">,</span> sample_data <span class="token operator">=</span> <span class="token string">"E:/Researches/lujia16S/Analysis_20200907/metadata.tsv"</span><span class="token punctuation">,</span> taxonomy_data <span class="token operator">=</span> <span class="token string">"E:/Researches/lujia16S/Analysis_20200907/taxonomy.qza"</span><span class="token punctuation">,</span> phylo_tree <span class="token operator">=</span> <span class="token string">"E:/Researches/lujia16S/Analysis_20200907/tree.qza"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="26"></td><td><pre></pre></td></tr><tr><td data-num="27"></td><td><pre>  meco_dataset</pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-4-数据预处理font"><a class="anchor" href="#font-colorff0000-4-数据预处理font">#</a> <font color="#FF0000">4. 数据预处理</font></h1><ul><li><p>移除未被分配到 &quot;k__Archaea&quot; 或 &quot;k__Bacteria&quot; 的 OTUs</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>meco_dataset<span class="token operator">$</span>tax_table <span class="token percent-operator operator">%&lt;>%</span> base<span class="token operator">::</span>subset<span class="token punctuation">(</span>Kingdom <span class="token operator">==</span> <span class="token string">"k__Archaea"</span> <span class="token operator">|</span> Kingdom <span class="token operator">==</span> <span class="token string">"k__Bacteria"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>  print<span class="token punctuation">(</span>meco_dataset<span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>移除注释为线粒体和叶绿体的 OTUs</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 移除 tax_table 中包含 taxa 名字的行，无论分类等级（taxonomic ranks），不区分大小写字母。简言之，taxa = c ("mitochondria", "chloroplast") 定义了删除包含 mitochondria 和 chloroplast 的行。</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>  meco_dataset<span class="token operator">$</span>filter_pollution<span class="token punctuation">(</span>taxa <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token string">"mitochondria"</span><span class="token punctuation">,</span> <span class="token string">"chloroplast"</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre>  print<span class="token punctuation">(</span>meco_dataset<span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>为了使 otu_table、tax_table 和 phylo_tree 中的 OTUs 相同，我们再次使用 tidy_dataset () 函数</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>meco_dataset<span class="token operator">$</span>tidy_dataset<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>  print<span class="token punctuation">(</span>meco_dataset<span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>调用 sample_sums () 检查各样本中的序列数量</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>meco_dataset<span class="token operator">$</span>sample_sums<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> range</pre></td></tr></table></figure></li><li><p>有时，为了减少物种数目对多样性度量的影响，我们需要进行重采样，使每个样本中的序列数量相等。函数 rarefy_samples 可以在稀疏（rarefying）前后自动调用函数 tidy_dataset。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># As an example, we use 20001 sequences in each sample</span></pre></td></tr><tr><td data-num="2"></td><td><pre>meco_dataset<span class="token operator">$</span>rarefy_samples<span class="token punctuation">(</span>sample.size <span class="token operator">=</span> <span class="token number">20001</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>meco_dataset<span class="token operator">$</span>sample_sums<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> range</pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-5-alpha多样性font"><a class="anchor" href="#font-colorff0000-5-alpha多样性font">#</a> <font color="#FF0000">5. alpha 多样性</font></h1><ul><li><p>然后，我们使用 cal_abund () 计算每个分类等级的分类单元丰度（taxa abundance）。此函数返回一个名为 taxa_abund 的列表，其中包含每个分类等级上的丰度信息的多个数据框。列表自动存储在 microtable object 中。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>meco_dataset<span class="token operator">$</span>cal_abund<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># return dataset$taxa_abund</span></pre></td></tr><tr><td data-num="3"></td><td><pre>class<span class="token punctuation">(</span>meco_dataset<span class="token operator">$</span>taxa_abund<span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>通过 save_abund () 将 taxa abundance 保存至本地文件</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>dir.create<span class="token punctuation">(</span><span class="token string">"taxa_abund"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>meco_dataset<span class="token operator">$</span>save_abund<span class="token punctuation">(</span>dirpath <span class="token operator">=</span> <span class="token string">"taxa_abund"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>计算 alpha 多样性。结果自动存储在 microtable object 中。<font color="#2196F3">作为示例，此处未计算系统发育多样性（phylogenetic diversity）</font>。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 若要计算 Faith's phylogenetic diversity，设置 PD = TRUE，计算速度会较慢</span></pre></td></tr><tr><td data-num="2"></td><td><pre>meco_dataset<span class="token operator">$</span>cal_alphadiv<span class="token punctuation">(</span>PD <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># return dataset$alpha_diversity</span></pre></td></tr><tr><td data-num="5"></td><td><pre>class<span class="token punctuation">(</span>meco_dataset<span class="token operator">$</span>alpha_diversity<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># save dataset$alpha_diversity to a directory</span></pre></td></tr><tr><td data-num="8"></td><td><pre>dir.create<span class="token punctuation">(</span><span class="token string">"alpha_diversity"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre>meco_dataset<span class="token operator">$</span>save_alphadiv<span class="token punctuation">(</span>dirpath <span class="token operator">=</span> <span class="token string">"alpha_diversity"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-6-β多样性font"><a class="anchor" href="#font-colorff0000-6-β多样性font">#</a> <font color="#FF0000">6. β 多样性</font></h1><ul><li><p>利用函数 cal_betadiv () 计算 beta - 多样性的距离矩阵。我们提供了四个最常用的索引：Bray-curtis、Jaccard、加权 Unifrac 和未加权 Unifrac。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># If you do not want to calculate unifrac metrics, use unifrac = FALSE</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># 需要 GUniFrac package</span></pre></td></tr><tr><td data-num="3"></td><td><pre>install.packages<span class="token punctuation">(</span><span class="token string">"GUniFrac"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre>meco_dataset<span class="token operator">$</span>cal_betadiv<span class="token punctuation">(</span>unifrac <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># return dataset$beta_diversity</span></pre></td></tr><tr><td data-num="7"></td><td><pre>class<span class="token punctuation">(</span>meco_dataset<span class="token operator">$</span>beta_diversity<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment"># save dataset$beta_diversity to a directory</span></pre></td></tr><tr><td data-num="10"></td><td><pre>dir.create<span class="token punctuation">(</span><span class="token string">"beta_diversity"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre>meco_dataset<span class="token operator">$</span>save_betadiv<span class="token punctuation">(</span>dirpath <span class="token operator">=</span> <span class="token string">"beta_diversity"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-7-trans_abund-classfont"><a class="anchor" href="#font-colorff0000-7-trans_abund-classfont">#</a> <font color="#FF0000">7. trans_abund class</font></h1><ul><li><p>绘制 Barplot。转换分类丰度数据，以便使用 ggplot2 包绘制分类单元丰度。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># create trans_abund object</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># use 12 Phyla with the highest abundance in the dataset.</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_abund<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> taxrank <span class="token operator">=</span> <span class="token string">"Phylum"</span><span class="token punctuation">,</span> ntaxa <span class="token operator">=</span> <span class="token number">12</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># t1 object now include the transformed abundance data t1$abund_data and other elements for the following plotting</span></pre></td></tr></table></figure></li><li><p>绘制 Barplot. We remove the sample names in x axis and add the facet to show abundance according to groups.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1<span class="token operator">$</span>plot_bar<span class="token punctuation">(</span>others_color <span class="token operator">=</span> <span class="token string">"grey70"</span><span class="token punctuation">,</span> facet <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> xtext_keep <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> legend_text_italic <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># return a ggplot2 object</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># 获取组内平均值。The groupmean parameter can be used to obtain the group-mean barplot.</span></pre></td></tr><tr><td data-num="5"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_abund<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> taxrank <span class="token operator">=</span> <span class="token string">"Phylum"</span><span class="token punctuation">,</span> ntaxa <span class="token operator">=</span> <span class="token number">12</span><span class="token punctuation">,</span> groupmean <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>plot_bar<span class="token punctuation">(</span>others_color <span class="token operator">=</span> <span class="token string">"grey70"</span><span class="token punctuation">,</span> legend_text_italic <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Then alluvial plot is implemented in the plot_bar function.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>install.packages<span class="token punctuation">(</span><span class="token string">"ggalluvial"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_abund<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> taxrank <span class="token operator">=</span> <span class="token string">"Phylum"</span><span class="token punctuation">,</span> ntaxa <span class="token operator">=</span> <span class="token number">12</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># use_alluvium = TRUE make the alluvial plot, clustering =TRUE can be used to reorder the samples by clustering</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t1<span class="token operator">$</span>plot_bar<span class="token punctuation">(</span>use_alluvium <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> clustering <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> xtext_type_hor <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> xtext_size <span class="token operator">=</span> <span class="token number">6</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>The box plot is an excellent way to intuitionally show data distribution across groups.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># show 15 taxa at Class level</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_abund<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> taxrank <span class="token operator">=</span> <span class="token string">"Class"</span><span class="token punctuation">,</span> ntaxa <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>plot_box<span class="token punctuation">(</span>group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><p><img data-src="#/images/lujia/show_15_taxa_at_Class_level.jpg" alt="show 15 taxa at Class level"></p><ul><li><p>Then we show the heatmap with the high abundant genera.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># show 40 taxa at Genus level</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_abund<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> taxrank <span class="token operator">=</span> <span class="token string">"Genus"</span><span class="token punctuation">,</span> ntaxa <span class="token operator">=</span> <span class="token number">40</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>plot_heatmap<span class="token punctuation">(</span>facet <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> xtext_keep <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> withmargin <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Then, we show the pie chart.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_abund<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> taxrank <span class="token operator">=</span> <span class="token string">"Phylum"</span><span class="token punctuation">,</span> ntaxa <span class="token operator">=</span> <span class="token number">6</span><span class="token punctuation">,</span> groupmean <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># all pie chart in one row</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>plot_pie<span class="token punctuation">(</span>facet_nrow <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-8-trans_venn-classfont"><a class="anchor" href="#font-colorff0000-8-trans_venn-classfont">#</a> <font color="#FF0000">8. trans_venn class</font></h1><ul><li><p>The trans_venn class is used for venn analysis. To analyze the unique and shared OTUs of groups, we first merge samples according to the “Group” column of sample_table.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># merge samples as one community for each group</span></pre></td></tr><tr><td data-num="2"></td><td><pre>dataset1 <span class="token operator">&lt;-</span> meco_dataset<span class="token operator">$</span>merge_samples<span class="token punctuation">(</span>use_group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># dataset1 is a new microtable object</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># create trans_venn object</span></pre></td></tr><tr><td data-num="5"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_venn<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset1<span class="token punctuation">,</span> ratio <span class="token operator">=</span> <span class="token string">"seqratio"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>plot_venn<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># The integer data is OTU number</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># The percentage data is the sequence number/total sequence number</span></pre></td></tr></table></figure></li><li><p>When the groups are too many to show with venn plot, we can use petal plot.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># use "Type" column in sample_table</span></pre></td></tr><tr><td data-num="2"></td><td><pre>dataset1 <span class="token operator">&lt;-</span> meco_dataset<span class="token operator">$</span>merge_samples<span class="token punctuation">(</span>use_group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_venn<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset1<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t1<span class="token operator">$</span>plot_venn<span class="token punctuation">(</span>petal_plot <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Sometimes, we are interested in the unique and shared species. In another words, the composition of the unique or shared species may account for the different and similar parts of ecological characteristics across groups[10]. For this goal, we first transform the results of venn plot to the traditional species-sample table, that is, another object of microtable class.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>dataset1 <span class="token operator">&lt;-</span> meco_dataset<span class="token operator">$</span>merge_samples<span class="token punctuation">(</span>use_group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_venn<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset1<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># transform venn results to the sample-species table, here do not consider abundance, only use presence/absence information.</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t2 <span class="token operator">&lt;-</span> t1<span class="token operator">$</span>trans_venn_com<span class="token punctuation">(</span>use_OTUs_frequency <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># t2 is a new microtable class, each part is considered as a sample</span></pre></td></tr><tr><td data-num="6"></td><td><pre>class<span class="token punctuation">(</span>t2<span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>We use bar plot to show the composition at the Genus level.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># calculate taxa abundance, that is, the frequency</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t2<span class="token operator">$</span>cal_abund<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># transform and plot</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t3 <span class="token operator">&lt;-</span> trans_abund<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> t2<span class="token punctuation">,</span> taxrank <span class="token operator">=</span> <span class="token string">"Genus"</span><span class="token punctuation">,</span> ntaxa <span class="token operator">=</span> <span class="token number">12</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre>t3<span class="token operator">$</span>plot_bar<span class="token punctuation">(</span>bar_type <span class="token operator">=</span> <span class="token string">"part"</span><span class="token punctuation">,</span> legend_text_italic <span class="token operator">=</span> T<span class="token punctuation">,</span> ylab_title <span class="token operator">=</span> <span class="token string">"Frequency (%)"</span><span class="token punctuation">,</span> xtext_type_hor <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>We also try to use pie chart to show the compositions at the Phylum level</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t3 <span class="token operator">&lt;-</span> trans_abund<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> t2<span class="token punctuation">,</span> taxrank <span class="token operator">=</span> <span class="token string">"Phylum"</span><span class="token punctuation">,</span> ntaxa <span class="token operator">=</span> <span class="token number">8</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t3<span class="token operator">$</span>plot_pie<span class="token punctuation">(</span>facet_nrow <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">,</span> use_colors <span class="token operator">=</span> rev<span class="token punctuation">(</span>c<span class="token punctuation">(</span>RColorBrewer<span class="token operator">::</span>brewer.pal<span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">,</span> <span class="token string">"Dark2"</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">"grey50"</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-9-trans_alpha-classfont"><a class="anchor" href="#font-colorff0000-9-trans_alpha-classfont">#</a> <font color="#FF0000">9. trans_alpha class</font></h1><ul><li><p>Alpha diversity can be transformed and plotted using trans_alpha class. Creating trans_alpha object can return two data frame: alpha_data and alpha_stat.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_alpha<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># return t1$alpha_stat</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>alpha_stat<span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">:</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token punctuation">]</span></pre></td></tr></table></figure></li><li><p>Then, we test the differences among groups using the KW rank sum test and anova with multiple comparisons.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1<span class="token operator">$</span>cal_diff<span class="token punctuation">(</span>method <span class="token operator">=</span> <span class="token string">"KW"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># return t1$res_alpha_diff</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>res_alpha_diff<span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">:</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token punctuation">]</span></pre></td></tr></table></figure><table><thead><tr><th>|Groups</th><th>Measure</th><th>Test method</th><th>p.value</th><th>Significance</th></tr></thead><tbody><tr><td>1|T16 vs T18</td><td>Observed</td><td>KW</td><td>2.601895e-03</td><td>**</td></tr><tr><td>2|T16 vs T20</td><td>Observed</td><td>KW</td><td>3.011399e-08</td><td>***</td></tr><tr><td>3|T16 vs T21</td><td>Observed</td><td>KW</td><td>2.174162e-04</td><td>***</td></tr><tr><td>4|T16 vs T17</td><td>Observed</td><td>KW</td><td>1.234229e-03</td><td>**</td></tr><tr><td>5|T18 vs T20</td><td>Observed</td><td>KW</td><td>7.319258e-08</td><td>***</td></tr></tbody></table><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1<span class="token operator">$</span>cal_diff<span class="token punctuation">(</span>method <span class="token operator">=</span> <span class="token string">"anova"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># return t1$res_alpha_diff</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>res_alpha_diff</pre></td></tr></table></figure><div style="overflow-x:auto"><table><table><thead><tr><th>Observed</th><th>Chao1</th><th>ACE</th><th>Shannon</th><th>Simpson</th><th>InvSimpson</th><th>Fisher</th><th>Coverage</th></tr></thead><tbody><tr><td>T18</td><td>a</td><td>a</td><td>a</td><td>a</td><td>a</td><td>a</td><td>a</td><td>c</td></tr><tr><td>T16</td><td>b</td><td>b</td><td>b</td><td>a</td><td>a</td><td>a</td><td>b</td><td>b</td></tr><tr><td>T17</td><td>c</td><td>c</td><td>c</td><td>b</td><td>a</td><td>b</td><td>c</td><td>b</td></tr><tr><td>T21</td><td>d</td><td>d</td><td>d</td><td>c</td><td>a</td><td>c</td><td>d</td><td>b</td></tr><tr><td>T20</td><td>e</td><td>e</td><td>e</td><td>d</td><td>b</td><td>d</td><td>e</td><td>a</td></tr></tbody></table></table></div></li><li><p>Now, let us plot the mean and se of alpha diversity for each group, and add the duncan.test (agricolae package) result.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1<span class="token operator">$</span>plot_alpha<span class="token punctuation">(</span>add_letter <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> measure <span class="token operator">=</span> <span class="token string">"Chao1"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>We can also use the boxplot to show the paired comparisons directly.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1<span class="token operator">$</span>plot_alpha<span class="token punctuation">(</span>pair_compare <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> measure <span class="token operator">=</span> <span class="token string">"Chao1"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-10-trans_beta-classfont"><a class="anchor" href="#font-colorff0000-10-trans_beta-classfont">#</a> <font color="#FF0000">10. trans_beta class</font></h1><ul><li><p>The distance matrix of beta diversity can be transformed and plotted using trans_beta class. The analysis referred to the beta diversity in this class mainly include ordination, group distance, clustering and manova. We first show the ordination using PCoA.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># we first create an object and select PCoA for ordination</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_beta<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> measure <span class="token operator">=</span> <span class="token string">"bray"</span><span class="token punctuation">,</span> ordination <span class="token operator">=</span> <span class="token string">"PCoA"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># t1$res_ordination is the ordination result list</span></pre></td></tr><tr><td data-num="4"></td><td><pre>class<span class="token punctuation">(</span>t1<span class="token operator">$</span>res_ordination<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># plot the PCoA result</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>plot_ordination<span class="token punctuation">(</span>plot_color <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> plot_shape <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> plot_group_ellipse <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Then we plot and compare the group distances.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># calculate and plot sample distances within groups</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_group_distance<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># return t1$res_group_distance</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t1<span class="token operator">$</span>plot_group_distance<span class="token punctuation">(</span>distance_pair_stat <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># calculate and plot sample distances between groups (报错：错误: Insufficient values in manual scale. 10 needed but only 8 provided.)</span></pre></td></tr><tr><td data-num="7"></td><td><pre>t1<span class="token operator">$</span>cal_group_distance<span class="token punctuation">(</span>within_group <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre>t1<span class="token operator">$</span>plot_group_distance<span class="token punctuation">(</span>distance_pair_stat <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Clustering plot is also a frequently used method.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># use replace_name to set the label name, group parameter used to set the color (报错：找不到对象 'dataset')</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>plot_clustering<span class="token punctuation">(</span>group <span class="token operator">=</span> <span class="token string">"Indexs"</span><span class="token punctuation">,</span> replace_name <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token string">"Water-depth(m)"</span><span class="token punctuation">,</span> <span class="token string">"Indexs"</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>perMANOVA is often used in the differential test of distances among groups.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># manova for all groups</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_manova<span class="token punctuation">(</span>cal_manova_all <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>res_manova<span class="token operator">$</span>aov.tab</pre></td></tr></table></figure><table><thead><tr><th colspan="7">ermutation: free</th></tr></thead><tbody><tr><td>umber of permutations: 999</td></tr><tr><td>erms added sequentially (first to last)</td></tr><tr><td>Df</td><td>SumsOfSqs</td><td>MeanSqs</td><td>F.Model</td><td>R<sup>2</sup></td><td>Pr(&gt;F)</td></tr><tr><td>ite</td><td>4</td><td>15.669</td><td>3.9173</td><td>19.445</td><td>0.48077</td><td>0.001 ***</td></tr><tr><td>esiduals</td><td>84</td><td>16.923</td><td colspan="2">0.2015</td><td>0.51923</td></tr><tr><td>otal</td><td>88</td><td colspan="3">32.592</td><td>1.00000</td></tr></tbody></table><p>&gt; Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</p></li></ul><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># manova for each paired groups</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_manova<span class="token punctuation">(</span>cal_manova_paired <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>res_manova</pre></td></tr></table></figure><table><thead><tr><th>Groups</th><th>measure</th><th>permutations</th><th>R<sup>2</sup></th><th>p.value</th><th>Significance</th></tr></thead><tbody><tr><td>1</td><td>T16 vs T18</td><td>bray</td><td>999</td><td>0.2748773</td><td>0.001</td><td>***</td></tr><tr><td>2</td><td>T16 vs T20</td><td>bray</td><td>999</td><td>0.4539103</td><td>0.001</td><td>***</td></tr><tr><td>3</td><td>T16 vs T21</td><td>bray</td><td>999</td><td>0.4102009</td><td>0.001</td><td>***</td></tr><tr><td>4</td><td>T16 vs T17</td><td>bray</td><td>999</td><td>0.2243404</td><td>0.001</td><td>***</td></tr><tr><td>5</td><td>T18 vs T20</td><td>bray</td><td>999</td><td>0.3736482</td><td>0.001</td><td>***</td></tr><tr><td>6</td><td>T18 vs T21</td><td>bray</td><td>999</td><td>0.3504104</td><td>0.001</td><td>***</td></tr><tr><td>7</td><td>T18 vs T17</td><td>bray</td><td>999</td><td>0.2147055</td><td>0.001</td><td>***</td></tr><tr><td>8</td><td>T20 vs T21</td><td>bray</td><td>999</td><td>0.3575765</td><td>0.001</td><td>***</td></tr><tr><td>9</td><td>T20 vs T17</td><td>bray</td><td>999</td><td>0.4589248</td><td>0.001</td><td>***</td></tr><tr><td>10</td><td>T21 vs T17</td><td>bray</td><td>999</td><td>0.4395176</td><td>0.001</td><td>***</td></tr></tbody></table><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># manova for specified group set: here "Group + Type"</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_manova<span class="token punctuation">(</span>cal_manova_set <span class="token operator">=</span> <span class="token string">"Site+ Indexs"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>res_manova<span class="token operator">$</span>aov.tab</pre></td></tr></table></figure><table><thead><tr><th colspan="7">Permutation: free</th></tr></thead><tbody><tr><td colspan="7">Number of permutations: 999</td></tr><tr><td colspan="7">Terms added sequentially (first to last)</td></tr><tr><td>Df</td><td>SumsOfSqs</td><td>MeanSqs</td><td>F.Model</td><td>R<sup>2</sup></td><td>Pr(F)</td></tr><tr><td>Site</td><td>4</td><td>15.669</td><td>4</td><td>0</td><td>0.48077</td><td>1</td></tr><tr><td>Indexs</td><td>84</td><td>16.923</td><td>0</td><td>0</td><td>0.51923</td><td>1</td></tr><tr><td>Residuals</td><td>0</td><td>0.000</td><td colspan="2">Inf</td><td colspan="2">0.00000</td></tr><tr><td>Total</td><td>88</td><td colspan="3">32.592</td><td colspan="2">1.00000</td></tr></tbody></table><h1 id="font-colorff0000-11-trans_diff-classfont"><a class="anchor" href="#font-colorff0000-11-trans_diff-classfont">#</a> <font color="#FF0000">11. trans_diff class</font></h1><ul><li><p>Differential abundance test is a very important part in the microbial community data analysis. It can be used to find the significant taxa in determining the community differences across groups. Currently, trans_diff class have three famous approaches to perform this analysis: metastat[11], LEfSe[12] and random forest. Metastat depends on the permutations and t-test and performs well on the sparse data. It is used for the comparisons between two groups.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># metastat analysis at Genus level</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_diff<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"metastat"</span><span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> metastat_taxa_level <span class="token operator">=</span> <span class="token string">"Genus"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># t1$res_metastat is the result</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># t1$res_metastat_group_matrix is the group comparisons order for plotting</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># plot the first paired groups, choose_group = 1</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>plot_metastat<span class="token punctuation">(</span>use_number <span class="token operator">=</span> <span class="token number">1</span><span class="token operator">:</span><span class="token number">10</span><span class="token punctuation">,</span> qvalue <span class="token operator">=</span> <span class="token number">0.05</span><span class="token punctuation">,</span> choose_group <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>LEfSe combines the non-parametric test and linear discriminant analysis. We implement this approach in this package instead of the python version.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_diff<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"lefse"</span><span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> alpha <span class="token operator">=</span> <span class="token number">0.01</span><span class="token punctuation">,</span> lefse_subgroup <span class="token operator">=</span> <span class="token keyword">NULL</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># t1$res_lefse is the LEfSe result</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># t1$res_abund is the abundance information</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t1<span class="token operator">$</span>plot_lefse_bar<span class="token punctuation">(</span>LDA_score <span class="token operator">=</span> <span class="token number">4</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>We can also plot the abundance of taxa detected using LEfSe.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1<span class="token operator">$</span>plot_diff_abund<span class="token punctuation">(</span>use_number <span class="token operator">=</span> <span class="token number">1</span><span class="token operator">:</span><span class="token number">30</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Then, we show the cladogram of the differential features in the taxonomic tree. There are too many taxa in this dataset. As an example, we only use the highest 200 abundant taxa in the tree and 50 differential features. We only show the full taxonomic label at Phylum level and use letters at other levels to reduce the text overlap.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># clade_label_level 5 represent phylum level in this analysis</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># require ggtree package</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>plot_lefse_cladogram<span class="token punctuation">(</span>use_taxa_num <span class="token operator">=</span> <span class="token number">200</span><span class="token punctuation">,</span> use_feature_num <span class="token operator">=</span> <span class="token number">50</span><span class="token punctuation">,</span> clade_label_level <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>There may be a problem related with the taxonomic labels in the plot. When the levels used are too many, the taxonomic labels may have too much overlap. However, if we only indicate the Phylum labels, the taxa in the legend with marked letters are too many. At this time, you can select the taxa that you want to show in the plot manually like the following operation.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># choose some taxa according to the positions in the previous picture; those taxa labels have minimum overlap</span></pre></td></tr><tr><td data-num="2"></td><td><pre>use_labels <span class="token operator">&lt;-</span> c<span class="token punctuation">(</span><span class="token string">"c__Deltaproteobacteria"</span><span class="token punctuation">,</span> <span class="token string">"c__Actinobacteria"</span><span class="token punctuation">,</span> <span class="token string">"o__Rhizobiales"</span><span class="token punctuation">,</span> <span class="token string">"p__Proteobacteria"</span><span class="token punctuation">,</span> <span class="token string">"p__Bacteroidetes"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="3"></td><td><pre>	<span class="token string">"o__Micrococcales"</span><span class="token punctuation">,</span> <span class="token string">"p__Acidobacteria"</span><span class="token punctuation">,</span> <span class="token string">"p__Verrucomicrobia"</span><span class="token punctuation">,</span> <span class="token string">"p__Firmicutes"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="4"></td><td><pre>	<span class="token string">"p__Chloroflexi"</span><span class="token punctuation">,</span> <span class="token string">"c__Acidobacteria"</span><span class="token punctuation">,</span> <span class="token string">"c__Gammaproteobacteria"</span><span class="token punctuation">,</span> <span class="token string">"c__Betaproteobacteria"</span><span class="token punctuation">,</span> <span class="token string">"c__KD4-96"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>	<span class="token string">"c__Bacilli"</span><span class="token punctuation">,</span> <span class="token string">"o__Gemmatimonadales"</span><span class="token punctuation">,</span> <span class="token string">"f__Gemmatimonadaceae"</span><span class="token punctuation">,</span> <span class="token string">"o__Bacillales"</span><span class="token punctuation">,</span> <span class="token string">"o__Rhodobacterales"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># then use parameter select_show_labels to show</span></pre></td></tr><tr><td data-num="7"></td><td><pre>t1<span class="token operator">$</span>plot_lefse_cladogram<span class="token punctuation">(</span>use_taxa_num <span class="token operator">=</span> <span class="token number">200</span><span class="token punctuation">,</span> use_feature_num <span class="token operator">=</span> <span class="token number">50</span><span class="token punctuation">,</span> select_show_labels <span class="token operator">=</span> use_labels<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># Now we can see that more taxa names appear in the tree</span></pre></td></tr></table></figure></li><li><p>If you are interested in taxonomic tree, you can also use metacoder package[13] to plot the taxonomic tree based on the selected taxa. We do not show the usage here.</p></li><li><p>The third approach is rf, which depends on the random forest[14, 15] and the non-parametric test. The current method can calculate random forest by bootstrapping like the method in LEfSe and only use the significant features. MeanDecreaseGini is selected as the indicator value in the analysis.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># use Genus level for parameter rf_taxa_level, if you want to use all taxa, change to "all"</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># nresam = 1 and boots = 1 represent no bootstrapping and use all samples directly</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_diff<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"rf"</span><span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> rf_taxa_level <span class="token operator">=</span> <span class="token string">"Genus"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># t1$res_rf is the result stored in the object</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># plot the result</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t2 <span class="token operator">&lt;-</span> t1<span class="token operator">$</span>plot_diff_abund<span class="token punctuation">(</span>use_number <span class="token operator">=</span> <span class="token number">1</span><span class="token operator">:</span><span class="token number">20</span><span class="token punctuation">,</span> only_abund_plot <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre>gridExtra<span class="token operator">::</span>grid.arrange<span class="token punctuation">(</span>t2<span class="token operator">$</span>p1<span class="token punctuation">,</span> t2<span class="token operator">$</span>p2<span class="token punctuation">,</span> ncol<span class="token operator">=</span><span class="token number">2</span><span class="token punctuation">,</span> nrow <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> widths <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># the middle asterisk represent the significances</span></pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-12-trans_env-classfont"><a class="anchor" href="#font-colorff0000-12-trans_env-classfont">#</a> <font color="#FF0000">12. trans_env class</font></h1><ul><li><p>分析环境因子对微生物群落结构和组装的影响：RDA 分析 (db-RDA 和 RDA).</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># add_data is used to add the environmental data</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_env<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> add_data <span class="token operator">=</span> env_data<span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token operator">:</span><span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># use bray-curtis distance to do dbrda</span></pre></td></tr><tr><td data-num="5"></td><td><pre>t1<span class="token operator">$</span>cal_rda<span class="token punctuation">(</span>use_dbrda <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> use_measure <span class="token operator">=</span> <span class="token string">"bray"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># t1$res_rda is the result list stored in the object</span></pre></td></tr><tr><td data-num="8"></td><td><pre>t1<span class="token operator">$</span>trans_rda<span class="token punctuation">(</span>adjust_arrow_length <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> max_perc_env <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment"># t1$res_rda_trans is the transformed result for plotting</span></pre></td></tr><tr><td data-num="11"></td><td><pre>t1<span class="token operator">$</span>plot_rda<span class="token punctuation">(</span>plot_color <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token comment"># use Genus</span></pre></td></tr><tr><td data-num="14"></td><td><pre>t1<span class="token operator">$</span>cal_rda<span class="token punctuation">(</span>use_dbrda <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> taxa_level <span class="token operator">=</span> <span class="token string">"Genus"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="15"></td><td><pre><span class="token comment"># As the main results of RDA are related with the projection and angles between different arrows,</span></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment"># we adjust the length of the arrow to show them clearly using several parameters.</span></pre></td></tr><tr><td data-num="17"></td><td><pre>t1<span class="token operator">$</span>trans_rda<span class="token punctuation">(</span>show_taxa <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">,</span> adjust_arrow_length <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> max_perc_env <span class="token operator">=</span> <span class="token number">1500</span><span class="token punctuation">,</span> max_perc_tax <span class="token operator">=</span> <span class="token number">3000</span><span class="token punctuation">,</span> min_perc_env <span class="token operator">=</span> <span class="token number">200</span><span class="token punctuation">,</span> min_perc_tax <span class="token operator">=</span> <span class="token number">300</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="18"></td><td><pre><span class="token comment"># t1$res_rda_trans is the transformed result for plotting</span></pre></td></tr><tr><td data-num="19"></td><td><pre>t1<span class="token operator">$</span>plot_rda<span class="token punctuation">(</span>plot_color <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Mantel test 用于检测环境因子和距离矩阵之间是否具有显著的相关性。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1<span class="token operator">$</span>cal_mantel<span class="token punctuation">(</span>use_measure <span class="token operator">=</span> <span class="token string">"bray"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># return t1$res_mantel</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>res_mantel</pre></td></tr></table></figure><div style="overflow-x:auto"><table><table><thead><tr><th>|variable_name</th><th>cor_method</th><th>corr_res</th><th>p_res</th><th>significance</th></tr></thead><tbody><tr><td>1|<strong>TN</strong></td><td>pearson</td><td>0.5571885</td><td>0.001</td><td>***</td></tr><tr><td>2|<strong>TC</strong></td><td>pearson</td><td>0.5712239</td><td>0.001</td><td>***</td></tr><tr><td>3|<strong>TS</strong></td><td>pearson</td><td>0.2665453</td><td>0.001</td><td>***</td></tr><tr><td>4|<strong>TOC</strong></td><td>pearson</td><td>0.3540337</td><td>0.001</td><td>***</td></tr><tr><td>5|<strong>Salinity</strong></td><td>pearson</td><td>0.2782537</td><td>0.001</td><td>***</td></tr><tr><td>6|Temperature</td><td>pearson</td><td>0.5856050</td><td>0.001</td><td>***</td></tr><tr><td>7|<strong>Dissolved.oxygen</strong></td><td>pearson</td><td>0.4358422</td><td>0.001</td><td>***</td></tr><tr><td>8|Surface.chlorophyll.concentrations</td><td>pearson</td><td>0.2586823</td><td>0.001</td><td>***</td></tr><tr><td>9|pH</td><td>pearson</td><td>0.4498964</td><td>0.001</td><td>***</td></tr><tr><td>10</td><td><strong>PAR</strong></td><td>pearson</td><td>0.1712861</td><td>0.001</td><td>***</td></tr><tr><td>11</td><td>Density</td><td>pearson</td><td>0.5682679</td><td>0.001</td><td>***</td></tr><tr><td>12</td><td>Turbidity</td><td>pearson</td><td>0.2260436</td><td>0.001</td><td>***</td></tr></tbody></table></table></div></li><li><p>环境变量与分类群（taxa）的相关性对分析和推断影响群落结构的因素具有重要意义。在本例中，我们首先进行了差异丰度检验（differential abundance test）和随机森林分析（random forest），得到了重要的属（Genus）。然后利用这些分类单元进行相关性分析。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># first create trans_diff object</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t2 <span class="token operator">&lt;-</span> trans_diff<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"rf"</span><span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> rf_taxa_level <span class="token operator">=</span> <span class="token string">"Genus"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># then create trans_env object</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_env<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> add_data <span class="token operator">=</span> env_data<span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token operator">:</span><span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># calculate correlation</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>cal_cor<span class="token punctuation">(</span>use_data <span class="token operator">=</span> <span class="token string">"other"</span><span class="token punctuation">,</span> p_adjust_method <span class="token operator">=</span> <span class="token string">"fdr"</span><span class="token punctuation">,</span> other_taxa <span class="token operator">=</span> t2<span class="token operator">$</span>res_rf<span class="token operator">$</span>Taxa<span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">:</span><span class="token number">60</span><span class="token punctuation">]</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># return t1$res_cor</span></pre></td></tr></table></figure></li><li><p>使用 ggplot2 或 pheatmap 进行可视化</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># default ggplot2 method</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>plot_corr<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># clustering heatmap; require pheatmap package</span></pre></td></tr><tr><td data-num="5"></td><td><pre>t1<span class="token operator">$</span>plot_corr<span class="token punctuation">(</span>pheatmap <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><p><img data-src="#/images/lujia/7%E4%B8%AA%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E4%B8%8E%E5%88%86%E7%B1%BB%E7%BE%A4ggplot2.jpg" alt="7个环境变量与分类群ggplot2"></p><p><img data-src="#/images/lujia/7%E4%B8%AA%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E4%B8%8E%E5%88%86%E7%B1%BB%E7%BE%A4%E7%9B%B8%E5%85%B3%E6%80%A7_pheatmap.jpg" alt="7个环境变量与分类群相关性_pheatmap"></p><ul><li><p>各组内的环境变量与分类群 taxa 之间的关系</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># calculate correlations for different groups using parameter by_group</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_cor<span class="token punctuation">(</span>by_group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> use_data <span class="token operator">=</span> <span class="token string">"other"</span><span class="token punctuation">,</span> p_adjust_method <span class="token operator">=</span> <span class="token string">"fdr"</span><span class="token punctuation">,</span> other_taxa <span class="token operator">=</span> t2<span class="token operator">$</span>res_rf<span class="token operator">$</span>Taxa<span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">:</span><span class="token number">60</span><span class="token punctuation">]</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># return t1$res_cor</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t1<span class="token operator">$</span>plot_corr<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><p><img data-src="#/images/lujia/correlations_between_environmental_variables_and_60_taxa.jpg" alt="correlations_between_environmental_variables_and_60_taxa"></p><ul><li><p>环境因子与 alpha - 多样性之间的关系</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_env<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> add_data <span class="token operator">=</span> env_data<span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token operator">:</span><span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># use add_abund_table parameter to add the extra data table</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>cal_cor<span class="token punctuation">(</span>add_abund_table <span class="token operator">=</span> meco_dataset<span class="token operator">$</span>alpha_diversity<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t1<span class="token operator">$</span>plot_corr<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><p><img data-src="#/images/lujia/relationship_between_7_environmental_factors_and_alpha_diversity.jpg" alt="relationship_between_7_environmental_factors_and_alpha_diversity"></p><h1 id="font-colorff0000-13-trans_nullmodel-classfont"><a class="anchor" href="#font-colorff0000-13-trans_nullmodel-classfont">#</a> <font color="#FF0000">13. trans_nullmodel class</font></h1><ul><li><p>近几十年来，系统发育分析和空模型（null model）的结合，通过增加系统发育维度（phylogeny dimension），更加有力地促进了生态位和中性（niche and neutral）对群落组装影响的推断 [16，17]。trans_nullmodel class 提供了一个封装，包括对系统发育信号、beta 平均成对系统发育距离（beta mean pairwise phylogenetic distance，betaMPD）、beta 平均最近分类单元距离（beta mean nearest taxon distance，betaMNTD）、beta 最近分类单元指数（beta nearest taxon index，betaNTI）、beta 净相关指数（beta net relatedness index，betaNRI）和基于 Bray-Curtis 的 Raup-Crick（Bray-Curtis-based Raup-Crick，RCbray）的计算。系统发育信号分析的方法基于 mantel 相关图（mantel correlogram）[18]，与其他方法相比，系统发育信号的变化是直观而清晰的。betaMNTD 和 betaMPD 的算法已经过优化，比 picante 包中的算法更快 [3]。RCbray 和 betaNTI（或 betaNRI）之间的组合可用于推断在特定假设下支配群落装配（community assembly）的每个生态过程（ecological process）的强度 [17]。这可以通过函数 cal_process () 来解析每个推断进程（ecological process）的百分比来实现。<font color="#2196F3"><strong>我们首先检查系统发育信号：</strong></font></p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># generate trans_nullmodel object; use 10000 OTUs as example</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_nullmodel<span class="token operator">$</span>new<span class="token punctuation">(</span>meco_dataset<span class="token punctuation">,</span> taxa_number <span class="token operator">=</span> <span class="token number">10000</span><span class="token punctuation">,</span> add_data <span class="token operator">=</span> env_data<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># use TOC as the test variable (__报错：Error in cor (as.vector (xdis), ydis, method = method, use = use) : </span></pre></td></tr><tr><td data-num="5"></td><td><pre>  cov<span class="token operator">/</span>cor中有遗漏值__<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>cal_mantel_corr<span class="token punctuation">(</span>use_env <span class="token operator">=</span> <span class="token string">"TOC"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># return t1$res_mantel_corr</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment"># plot the mantel correlogram (__报错：Error in names (x) &lt;- value : 'names' 属性的长度 [4] 必需和矢量的长度 [0] 一样__)</span></pre></td></tr><tr><td data-num="10"></td><td><pre>t1<span class="token operator">$</span>plot_mantel_corr<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>betaNRI（ses.betampd）用于显示 “basal” 系统发育转换（phylogenetic turnover）[18]。与 betaNTI 相比，它能捕获更多与深层系统发育（deep phylogeny）相关的转换信息（turnover information）。值得注意的是，经过几十年的发展，出现了许多空模型（null models）。在 trans-nullmodel class 中，我们随机化了物种的系统发育相关性。这种洗牌方法（shuffling approach）固定了观察到的物种 α- 多样性和 β- 多样性的水平，以探讨观察到的系统发育转换是否与空模型（物种间的系统发育关系是随机的）显著不同。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 运行 500 次 null model</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_ses_betampd<span class="token punctuation">(</span>runs<span class="token operator">=</span><span class="token number">500</span><span class="token punctuation">,</span> abundance.weighted <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># 返回 t1$res_ses_betampd</span></pre></td></tr></table></figure></li><li><p>可以使用 trans_beta class 中的 plot_group_distance function 绘制 betaNRI 图。结果表明 T20 和 T21 的平均 betaNRI 显著高于其它三者，表明 T20 和 T21 中的 basal phylogenetic turnover 是高的。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 将 betaNRI 矩阵加入到 beta_diversity 列表中</span></pre></td></tr><tr><td data-num="2"></td><td><pre>meco_dataset<span class="token operator">$</span>beta_diversity<span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token string">"betaNRI"</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">&lt;-</span> t1<span class="token operator">$</span>res_ses_betampd</pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># 使用 measure "betaNRI" 创建 trans_beta class</span></pre></td></tr><tr><td data-num="5"></td><td><pre>t2 <span class="token operator">&lt;-</span> trans_beta<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> measure <span class="token operator">=</span> <span class="token string">"betaNRI"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># transform the distance for each group</span></pre></td></tr><tr><td data-num="8"></td><td><pre>t2<span class="token operator">$</span>cal_group_distance<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment"># 结果可视化</span></pre></td></tr><tr><td data-num="11"></td><td><pre>library<span class="token punctuation">(</span>ggplot2<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre>g1 <span class="token operator">&lt;-</span> t2<span class="token operator">$</span>plot_group_distance<span class="token punctuation">(</span>distance_pair_stat <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="13"></td><td><pre>g1 <span class="token operator">+</span> geom_hline<span class="token punctuation">(</span>yintercept <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span> linetype <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">+</span> geom_hline<span class="token punctuation">(</span>yintercept <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">,</span> linetype <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><p><img data-src="#/images/lujia/betaNRI_all.jpg" alt="betaNRI all"></p><ul><li><p>若要单独的对每个组进行 null model analysis，例如每个组作为一个物种池（species pool），我们可以分别为每个组计算结果。 我们发现，当分别对每个组进行 betaNRI 分析时，CW 和 TW 间的 mean betaNRI 没有显著差异，且二者均显著高于 IW ，揭示了在将每个区域视为特定物种库的条件下，CW 和 TW 中变量选择的强度（strength of variable selection）可能相似。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 创建一个列表用于存放 trans_nullmodel 的结果</span></pre></td></tr><tr><td data-num="2"></td><td><pre>sesbeta_each <span class="token operator">&lt;-</span> list<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>group_col <span class="token operator">&lt;-</span> <span class="token string">"Site"</span></pre></td></tr><tr><td data-num="4"></td><td><pre>all_groups <span class="token operator">&lt;-</span> unique<span class="token punctuation">(</span>meco_dataset<span class="token operator">$</span>sample_table<span class="token punctuation">[</span><span class="token punctuation">,</span> group_col<span class="token punctuation">]</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># 对每个组分别进行计算</span></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token keyword">for</span><span class="token punctuation">(</span>i <span class="token keyword">in</span> all_groups<span class="token punctuation">)</span><span class="token punctuation">&#123;</span></pre></td></tr><tr><td data-num="8"></td><td><pre>	<span class="token comment"># like the above operation, but need provide 'group' and 'select_group'</span></pre></td></tr><tr><td data-num="9"></td><td><pre>	test <span class="token operator">&lt;-</span> trans_nullmodel<span class="token operator">$</span>new<span class="token punctuation">(</span>meco_dataset<span class="token punctuation">,</span> group <span class="token operator">=</span> group_col<span class="token punctuation">,</span> select_group <span class="token operator">=</span> i<span class="token punctuation">,</span> taxa_number <span class="token operator">=</span> <span class="token number">1000</span><span class="token punctuation">,</span> add_data <span class="token operator">=</span> env_data<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre>	test<span class="token operator">$</span>cal_ses_betampd<span class="token punctuation">(</span>runs <span class="token operator">=</span> <span class="token number">500</span><span class="token punctuation">,</span> abundance.weighted <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre>	sesbeta_each<span class="token punctuation">[</span><span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">&lt;-</span> test<span class="token operator">$</span>res_ses_betampd</pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token punctuation">&#125;</span></pre></td></tr><tr><td data-num="13"></td><td><pre></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment"># 合并结果并重塑（reshape），得到一个对称矩阵（symmetrical matrix）</span></pre></td></tr><tr><td data-num="15"></td><td><pre>library<span class="token punctuation">(</span>reshape2<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="16"></td><td><pre>test <span class="token operator">&lt;-</span> lapply<span class="token punctuation">(</span>sesbeta_each<span class="token punctuation">,</span> melt<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> do.call<span class="token punctuation">(</span>rbind<span class="token punctuation">,</span> .<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> reshape2<span class="token operator">::</span>dcast<span class="token punctuation">(</span>.<span class="token punctuation">,</span> Var1<span class="token operator">~</span>Var2<span class="token punctuation">,</span> value.var <span class="token operator">=</span> <span class="token string">"value"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> `row.names<span class="token operator">&lt;-</span>`<span class="token punctuation">(</span>.<span class="token punctuation">[</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> .<span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span> drop <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">]</span></pre></td></tr><tr><td data-num="17"></td><td><pre></pre></td></tr><tr><td data-num="18"></td><td><pre><span class="token comment"># 如同上述操作</span></pre></td></tr><tr><td data-num="19"></td><td><pre>meco_dataset<span class="token operator">$</span>beta_diversity<span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token string">"betaNRI"</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">&lt;-</span> test</pre></td></tr><tr><td data-num="20"></td><td><pre>t2 <span class="token operator">&lt;-</span> trans_beta<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> measure <span class="token operator">=</span> <span class="token string">"betaNRI"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="21"></td><td><pre>t2<span class="token operator">$</span>cal_group_distance<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="22"></td><td><pre>g1 <span class="token operator">&lt;-</span> t2<span class="token operator">$</span>plot_group_distance<span class="token punctuation">(</span>distance_pair_stat <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="23"></td><td><pre>g1 <span class="token operator">+</span> geom_hline<span class="token punctuation">(</span>yintercept <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span> linetype <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">+</span> geom_hline<span class="token punctuation">(</span>yintercept <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">,</span> linetype <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><p><img data-src="#/images/lujia/betaNRI_individual.jpg" alt="betaNRI individual"></p><ul><li><p>BetaNTI (ses.betamntd) 可用于指示系统发育的末端转换（ phylogenetic terminal turnover） [17]</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 运行 500 次 null model</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_ses_betamntd<span class="token punctuation">(</span>runs<span class="token operator">=</span><span class="token number">500</span><span class="token punctuation">,</span> abundance.weighted <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># 返回 t1$res_ses_betamntd</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># 将 betaNTI 矩阵加入到 beta_diversity 列表中</span></pre></td></tr><tr><td data-num="6"></td><td><pre>meco_dataset<span class="token operator">$</span>beta_diversity<span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token string">"betaNTI"</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">&lt;-</span> t1<span class="token operator">$</span>res_ses_betamntd</pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># 使用 measure "betaNRI" 创建 trans_beta class</span></pre></td></tr><tr><td data-num="9"></td><td><pre>t2 <span class="token operator">&lt;-</span> trans_beta<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> group <span class="token operator">=</span> <span class="token string">"Site"</span><span class="token punctuation">,</span> measure <span class="token operator">=</span> <span class="token string">"betaNTI"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token comment"># transform the distance for each group</span></pre></td></tr><tr><td data-num="12"></td><td><pre>t2<span class="token operator">$</span>cal_group_distance<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="13"></td><td><pre></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment"># 结果可视化</span></pre></td></tr><tr><td data-num="15"></td><td><pre>library<span class="token punctuation">(</span>ggplot2<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="16"></td><td><pre>g1 <span class="token operator">&lt;-</span> t2<span class="token operator">$</span>plot_group_distance<span class="token punctuation">(</span>distance_pair_stat <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="17"></td><td><pre>g1 <span class="token operator">+</span> geom_hline<span class="token punctuation">(</span>yintercept <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span> linetype <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">+</span> geom_hline<span class="token punctuation">(</span>yintercept <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">,</span> linetype <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>cal_rcbray () 功能用于计算 RCbray (Bray-Curtis-based Raup-Crick) ，以评估成分转换（compositional turnover）是否主要受漂移控制 [19]。我们应用空模型（null model）通过从每个物种池中随机采样个体来模拟物种分布，同时保留物种发生频率（species occurrence frequency）和样本物种丰富度（sample species richness）[18]。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># result stored in t1$res_rcbray</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_rcbray<span class="token punctuation">(</span>runs <span class="token operator">=</span> <span class="token number">1000</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># return t1$res_rcbray</span></pre></td></tr></table></figure></li><li><p>作为一个例子，我们还计算了引用文献 [17，18] 中所示的在群落组装（community assembly）上推断过程（ inferred processes ）所占的比例。在此示例中，具有显着 betaNTI 值（|βNTI|&gt; 2）的成对比较部分是估计的选择（Selection）造成影响； βNTI&gt; 2 代表异构选择（heterogeneous ）； βNTI&lt;-2 表示同质选择（homogeneous ）。 RCbray 值表征了随机分配（randomization）下观察到的 Bray-Curtis 和 Bray-Curtis 期望值之间的偏差大小（magnitude of deviation）。 | RCbray | &gt; 0.95 被认为是显着的。 |βNTI| &lt; 2 和 RCbray &gt; +0.95 被视为受散播限制（Dispersal Limitation）与漂移（Drift）相结合的影响。 |βNTI| &lt; 2 和 RCbray &lt; -0.95 被视为均质分散（Homogenizing Dispersal）影响的估计值。 |βNTI| &lt; 2 和 | RCbray| &lt; 0.95 估算了漂移单独作用的影响。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># use betaNTI and rcbray to evaluate processes</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_process<span class="token punctuation">(</span>use_betamntd <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># return t1$res_process</span></pre></td></tr><tr><td data-num="5"></td><td><pre>t1<span class="token operator">$</span>res_process</pre></td></tr></table></figure><table><thead><tr><th></th><th>process</th><th>percentage</th></tr></thead><tbody><tr><td>1</td><td>variable selection</td><td>0.4341164</td></tr><tr><td>2</td><td>homogeneous selection</td><td>63.6874362</td></tr><tr><td>3</td><td>dispersal limitation</td><td>0.0000000</td></tr><tr><td>4</td><td>homogeneous dispersal</td><td>14.8365679</td></tr><tr><td>5</td><td>drift</td><td>21.0418795</td></tr></tbody></table></li></ul><h1 id="font-colorff0000-14-trans_network-classfont"><a class="anchor" href="#font-colorff0000-14-trans_network-classfont">#</a> <font color="#FF0000">14. trans_network class</font></h1><h2 id="font-colorff9800-correlation-based-networkfont"><a class="anchor" href="#font-colorff9800-correlation-based-networkfont">#</a> <font color="#FF9800">correlation-based network</font></h2><ul><li>准备 R 包并进行计算相关性<figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>install.packages<span class="token punctuation">(</span><span class="token string">"WGCNA"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>library<span class="token punctuation">(</span>WGCNA<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># 以下 3 选 1</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># 1. Use R base cor.test, slow</span></pre></td></tr><tr><td data-num="5"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_network<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> cal_cor <span class="token operator">=</span> <span class="token string">"base"</span><span class="token punctuation">,</span> taxa_level <span class="token operator">=</span> <span class="token string">"OTU"</span><span class="token punctuation">,</span> filter_thres <span class="token operator">=</span> <span class="token number">0.0001</span><span class="token punctuation">,</span> cor_method <span class="token operator">=</span> <span class="token string">"spearman"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># return t1$res_cor_p list; one table: correlation; another: p value</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># 2. SparCC method, require SpiecEasi package</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment"># SparCC is very slow, so consider filtering more species with low abundance</span></pre></td></tr><tr><td data-num="10"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_network<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> meco_dataset<span class="token punctuation">,</span> cal_cor <span class="token operator">=</span> <span class="token string">"SparCC"</span><span class="token punctuation">,</span> taxa_level <span class="token operator">=</span> <span class="token string">"OTU"</span><span class="token punctuation">,</span> filter_thres <span class="token operator">=</span> <span class="token number">0.001</span><span class="token punctuation">,</span> SparCC_simu_num <span class="token operator">=</span> <span class="token number">100</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token comment"># 3. When the OTU number is large, use R WGCNA package to replace R base to calculate correlations</span></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token comment"># require WGCNA package</span></pre></td></tr><tr><td data-num="14"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_network<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> dataset<span class="token punctuation">,</span> cal_cor <span class="token operator">=</span> <span class="token string">"WGCNA"</span><span class="token punctuation">,</span> taxa_level <span class="token operator">=</span> <span class="token string">"OTU"</span><span class="token punctuation">,</span> filter_thres <span class="token operator">=</span> <span class="token number">0.0001</span><span class="token punctuation">,</span> cor_method <span class="token operator">=</span> <span class="token string">"spearman"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h2 id="font-colorff9800-构建网络font"><a class="anchor" href="#font-colorff9800-构建网络font">#</a> <font color="#FF9800">构建网络</font></h2><ul><li><p>COR_optimization = TRUE represent using RMT theory to find the optimized correlation threshold instead of the COR_cut.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># construct network; require igraph package</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_network<span class="token punctuation">(</span>p_thres <span class="token operator">=</span> <span class="token number">0.01</span><span class="token punctuation">,</span> COR_optimization <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># return t1$res_network</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># (可选) use arbitrary coefficient threshold to contruct network</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>cal_network<span class="token punctuation">(</span>p_thres <span class="token operator">=</span> <span class="token number">0.01</span><span class="token punctuation">,</span> COR_cut <span class="token operator">=</span> <span class="token number">0.73</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># save network</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment"># open the gexf file using Gephi(https://gephi.org/)</span></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment"># require rgexf package</span></pre></td></tr><tr><td data-num="11"></td><td><pre>install.packages<span class="token punctuation">(</span><span class="token string">"rgexf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre>t1<span class="token operator">$</span>save_network<span class="token punctuation">(</span>filepath <span class="token operator">=</span> <span class="token string">"network.gexf"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Now, we show the node colors with the Phylum information and the edges colors with the positive and negative correlations. All the data used has been stored in the network.gexf file, including modules classifications, Phylum information and edges classifications.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># calculate network attributes</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t1<span class="token operator">$</span>cal_network_attr<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># return t1$res_network_attr</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># classify the node; return t1$res_node_type</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>cal_node_type<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># return t1$res_node_type</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># we retain the file for the following example in trans_func part</span></pre></td></tr><tr><td data-num="9"></td><td><pre>network_node_type <span class="token operator">&lt;-</span> t1<span class="token operator">$</span>res_node_type</pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token comment"># plot node roles in terms of the within-module connectivity and among-module connectivity</span></pre></td></tr><tr><td data-num="12"></td><td><pre>t1<span class="token operator">$</span>plot_taxa_roles<span class="token punctuation">(</span>use_type <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="13"></td><td><pre></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment"># plot node roles with phylum information</span></pre></td></tr><tr><td data-num="15"></td><td><pre>t1<span class="token operator">$</span>plot_taxa_roles<span class="token punctuation">(</span>use_type <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>Now, we show the eigengene analysis of modules. The eigengene of a module, i.e. the first principal component of PCA, represents the main variance of the abundance in the species of the module.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1<span class="token operator">$</span>cal_eigen<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># return t1$res_eigen</span></pre></td></tr></table></figure></li><li><p><strong>出错了</strong>！Then we perform correlation heatmap to show the relationships between eigengenes and environmental factors.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># create trans_env object like the above operation</span></pre></td></tr><tr><td data-num="2"></td><td><pre>t2 <span class="token operator">&lt;-</span> trans_env<span class="token operator">$</span>new<span class="token punctuation">(</span>dataset <span class="token operator">=</span> dataset<span class="token punctuation">,</span> add_data <span class="token operator">=</span> env_data_16S<span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token operator">:</span><span class="token number">11</span><span class="token punctuation">]</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># calculate correlations</span></pre></td></tr><tr><td data-num="4"></td><td><pre>t2<span class="token operator">$</span>cal_cor<span class="token punctuation">(</span>add_abund_table <span class="token operator">=</span> t1<span class="token operator">$</span>res_eigen<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># plot the correlation heatmap</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t2<span class="token operator">$</span>plot_corr<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>The function cal_sum_links() is used to sum the links (edge) number from one taxa to another or in the same taxa. The function plot_sum_links() is used to show the result from the function cal_sum_links(). This is very useful to fast see how many nodes are connected between different taxa or within one taxa. In terms of “Phylum” level in the tutorial, the function cal_sum_links() sum the linkages number from one Phylum to another Phylum or the linkages in the same Phylum. So the numbers along the outside of the circular plot represent how many edges or linkages are related with the Phylum. For example, in terms of Proteobacteria, there are roughly total 900 edges associated with the OTUs in Proteobacteria, in which roughly 200 edges connect both OTUs in Proteobacteria and roughly 150 edges connect the OTUs from Proteobacteria with the OTUs from Chloroflexi.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>devtools<span class="token operator">::</span>install_github<span class="token punctuation">(</span><span class="token string">"mattflor/chorddiag"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># calculate the links between or within taxonomic ranks (报错：Error in ecount (network) : 没有 "ecount" 这个函数)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t1<span class="token operator">$</span>cal_sum_links<span class="token punctuation">(</span>taxa_level <span class="token operator">=</span> <span class="token string">"Phylum"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># return t1$res_sum_links_pos and t1$res_sum_links_neg</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># require chorddiag package</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>plot_sum_links<span class="token punctuation">(</span>plot_pos <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> plot_num <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-15-trans_func-classfont"><a class="anchor" href="#font-colorff0000-15-trans_func-classfont">#</a> <font color="#FF0000">15. trans_func class</font></h1><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># Identify microbial traits</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># create object of trans_func</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t2 <span class="token operator">&lt;-</span> trans_func<span class="token operator">$</span>new<span class="token punctuation">(</span>meco_dataset<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># mapping the taxonomy to the database</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># the function can recognize prokaryotes or fungi automatically</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t2<span class="token operator">$</span>cal_spe_func<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># return t2$res_spe_func, 1 represent function exists, 0 represent no or cannot confirmed.</span></pre></td></tr></table></figure><ul><li><p>The percentages of the OTUs having the same trait can reflect the functional redundancy of this function in the community or the module in the network.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># calculate the percentages of OTUs for each trait in each module of network</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># use_community = FALSE represent calculating module, not community, node_type_table provide the module information</span></pre></td></tr><tr><td data-num="3"></td><td><pre>t2<span class="token operator">$</span>cal_spe_func_perc<span class="token punctuation">(</span>use_community <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> node_type_table <span class="token operator">=</span> network_node_type<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># return t2$res_spe_func_perc</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># we only plot some important traits, so we use the default group list to filter and show the traits.</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t2<span class="token operator">$</span>plot_spe_func_perc<span class="token punctuation">(</span>select_samples <span class="token operator">=</span> paste0<span class="token punctuation">(</span><span class="token string">"M"</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token operator">:</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># M represents module, ordered by the nodes number from high to low</span></pre></td></tr></table></figure></li><li><p>Tax4Fun requires a strict input file demand on the taxonomic information. To analyze the trimmed or changed OTU data in R with Tax4Fun, we provide a link to the Tax4Fun functional prediction.</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>t1 <span class="token operator">&lt;-</span> trans_func<span class="token operator">$</span>new<span class="token punctuation">(</span>meco_dataset<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token comment"># install Tax4Fun package and download SILVA123 ref data from  http://tax4fun.gobics.de/</span></pre></td></tr><tr><td data-num="3"></td><td><pre>wget https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>github.com<span class="token operator">/</span>bwemheu<span class="token operator">/</span>Tax4Fun2<span class="token operator">/</span>releases<span class="token operator">/</span>download<span class="token operator">/</span><span class="token number">1.1</span><span class="token number">.5</span><span class="token operator">/</span>Tax4Fun2_1.<span class="token number">1.5</span>.tar.gz</pre></td></tr><tr><td data-num="4"></td><td><pre>install.packages<span class="token punctuation">(</span>pkgs <span class="token operator">=</span> <span class="token string">"Tax4Fun2_1.1.5.tar.gz"</span><span class="token punctuation">,</span> repos <span class="token operator">=</span> <span class="token keyword">NULL</span><span class="token punctuation">,</span> source <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># decompress SILVA123; provide path in folderReferenceData as you put</span></pre></td></tr><tr><td data-num="6"></td><td><pre>t1<span class="token operator">$</span>cal_tax4fun<span class="token punctuation">(</span>folderReferenceData <span class="token operator">=</span> <span class="token string">"./SILVA123"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># return two files: t1$tax4fun_KO: KO file; t1$tax4fun_path: pathway file.</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># t1$tax4fun_KO$Tax4FunProfile[1:5, 1:2]</span></pre></td></tr></table></figure></li></ul><h1 id="font-colorff0000-16-知识点font"><a class="anchor" href="#font-colorff0000-16-知识点font">#</a> <font color="#FF0000">16. 知识点</font></h1><h2 id="font-colorff9800-确定性过程和随机过程font"><a class="anchor" href="#font-colorff9800-确定性过程和随机过程font">#</a> <font color="#FF9800">确定性过程和随机过程</font></h2><ul><li><p>The term <font color="#2196F3" size="5"><b>“deterministic process”</b></font> refers to two types of selective forces, namely, those that lead to either more (i.e. homogeneous selection) or less (i.e. heterogeneous selection) similar structures among communities due to homogeneous and heterogeneous environmental pressures, respectively (Zhou &amp; Ning, 2017). <font color="#2196F3" size="5"><b>确定性过程</b></font>包括两种选择力，即分别导致更加相似（即同质选择）或更少相似（即异质选择）的群落间的结构的同质和异质环境压力。</p></li><li><p>The term<font color="#2196F3" size="5"><b> “stochastic process” </b></font>refers to homogenizing dispersal, dispersal limitation (combined with drift) and pure drift, which can obscure the turnover among microbial communities due to high dispersal; low dispersal; and random changes in birth, death and reproduction, respectively (Zhou &amp; Ning, 2017). <font color="#2196F3" size="5"><b>随机过程</b></font>是指均匀分散、分散限制（结合漂变）和纯漂变，它们可以通过高度分散、低分散和出生、死亡和繁殖的随机变化来掩盖 / 减弱微生物群落之间的更替。</p></li></ul><p><img data-src="/images/lujia/nullmodel.png" alt="Community assembly processes by Stegen et al. https://www.nature.com/articles/ismej201393"></p><ul><li>An NTI of &gt;+2 indicates that the ASVs in a local community are more closely related than expected by chance, suggesting the role of selective pressures (e.g. environmental conditions) in phylogenetic clustering. An NTI of &lt;−2 represents phylogenetic overdispersion, indicating two possible biotic interactions: competition and facilitation. In contrast, a mean NTI across multiple communities that is significantly greater or less than zero indicates phylogenetic clustering or overdispersion, respectively (Zhou &amp; Ning, 2017). NTI &gt;2 表明，在一个地方群落中，ASVs 的亲缘关系比预期的更为密切，表明选择压力（如环境条件）在系统发育聚类中的作用。NTI &lt;-2 表示系统发育过度分散，表明两种可能的生物相互作用：竞争和促进。相反，多个群落间的平均 NTI 显著大于或小于零，分别表明系统发育聚类或过度分散（Zhou 和 Ning，2017）。</li><li>βNTI&gt;+2 or &lt;−2 signified heterogeneous selection or homogeneous selection, respectively. βNTI&gt;+2 or &lt;−2 分别指示异质选择和同质选择。</li></ul><h1 id="font-colorff0000-17-参考font"><a class="anchor" href="#font-colorff0000-17-参考font">#</a> <font color="#FF0000">17. 参考</font></h1><ul><li><span class="exturl" data-url="aHR0cHM6Ly9jaGlsaXViaW8uZ2l0aHViLmlvL21pY3JvZWNvLw==">https://chiliubio.github.io/microeco/</span></li><li>Zhou, J., &amp; Ning, D. (2017). Stochastic community assembly: Does it matter in microbial ecology? Microbiology and Molecular Biology Reviews, 81(4), e00002–17. <span class="exturl" data-url="aHR0cHM6Ly9kb2kub3JnLzEwLjExMjgvTU1CUi4wMDAwMiVFMiU4MCU5MDE3">https://doi.org/10.1128/MMBR.00002‐17</span></li><li><span class="exturl" data-url="aHR0cDovL3d3dy4zNjBkb2MuY29tL2NvbnRlbnQvMjAvMTIyMy8wNy83MTg3NDk0OF85NTI5NjY0NDIuc2h0bWw=">http://www.360doc.com/content/20/1223/07/71874948_952966442.shtml</span></li></ul><div class="tags"><a href="/tags/%E6%89%A9%E5%A2%9E%E5%AD%90/" rel="tag"><i class="ic i-tag"></i> 扩增子</a></div></div><footer><div class="meta"><span class="item"><span class="icon"><i class="ic i-calendar-check"></i> </span><span class="text">Edited on</span> <time title="Modified: 2022-05-31 09:41:33" itemprop="dateModified" datetime="2022-05-31T09:41:33+08:00">2022-05-31</time> </span><span id="post/4cf4.html" class="item leancloud_visitors" data-flag-title="Use microeco分析扩增子数据" title="Views"><span class="icon"><i class="ic i-eye"></i> </span><span class="text">Views</span> <span class="leancloud-visitors-count"></span> <span class="text">times</span></span></div><div class="reward"><button><i class="ic i-heartbeat"></i> Donate</button><p>Give me a cup of [coffee]~(￣▽￣)~*</p><div id="qr"><div><img data-src="/images/reward-wepays.jpg" alt="Hualin Liu WeChat Pay"><p>WeChat Pay</p></div><div><img data-src="/images/AliPays.jpg" alt="Hualin Liu Alipay"><p>Alipay</p></div></div></div><div id="copyright"><ul><li class="author"><strong>Post author: </strong>liaochenlanruo <i class="ic i-at"><em>@</em></i>了尘兰若的小坑</li><li class="link"><strong>Post link: </strong><a href="https://liaochenlanruo.gitee.io/post/4cf4.html" title="Use microeco分析扩增子数据">https://liaochenlanruo.gitee.io/post/4cf4.html</a></li><li class="license"><strong>Copyright Notice: </strong>All articles in this blog are licensed under <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzQuMC9kZWVkLnpo"><i class="ic i-creative-commons"><em>(CC)</em></i>BY-NC-SA</span> unless stating additionally.</li></ul></div></footer></article></div><div class="post-nav"><div class="item left"><a href="/post/ab1b.html" itemprop="url" rel="prev" data-background-image="https:&#x2F;&#x2F;fastly.jsdelivr.net&#x2F;gh&#x2F;liaochenlanruo&#x2F;cdn@master&#x2F;img&#x2F;custom&#x2F;bgs&#x2F;thumb_41.webp" title="宏基因组分析流程及代码"><span class="type">Previous Post</span> <span class="category"><i class="ic i-flag"></i> 生物信息</span><h3>宏基因组分析流程及代码</h3></a></div><div class="item right"><a href="/post/1755.html" itemprop="url" rel="next" data-background-image="https:&#x2F;&#x2F;fastly.jsdelivr.net&#x2F;gh&#x2F;liaochenlanruo&#x2F;cdn@master&#x2F;img&#x2F;custom&#x2F;bgs&#x2F;thumb_53.webp" title="扩增子分析--计算随机过程和决定性过程比例"><span class="type">Next Post</span> <span class="category"><i class="ic i-flag"></i> 生物信息</span><h3>扩增子分析--计算随机过程和决定性过程比例</h3></a></div></div><div class="wrap" id="comments"></div></div><div id="sidebar"><div class="inner"><div class="panels"><div class="inner"><div class="contents panel pjax" data-title="Contents"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-1-%E5%AE%89%E8%A3%85microecofont"><span class="toc-number">1.</span> <span class="toc-text">1. 安装 microeco</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-2-%E5%87%86%E5%A4%87%E6%95%B0%E6%8D%AEfont"><span class="toc-number">2.</span> <span class="toc-text">2. 准备数据</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#font-colorff9800-otu_tablefont"><span class="toc-number">2.1.</span> <span class="toc-text">otu_table</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#font-colorff9800-taxonomy_tablefont"><span class="toc-number">2.2.</span> <span class="toc-text">taxonomy_table</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#font-colorff9800-sample_infofont"><span class="toc-number">2.3.</span> <span class="toc-text">sample_info</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#font-colorff9800-env_datafont"><span class="toc-number">2.4.</span> <span class="toc-text">env_data</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#font-colorff9800-phylo_treefont"><span class="toc-number">2.5.</span> <span class="toc-text">phylo_tree</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-3-%E5%AF%BC%E5%85%A5%E6%95%B0%E6%8D%AEfont"><span class="toc-number">3.</span> <span class="toc-text">3. 导入数据</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-4-%E6%95%B0%E6%8D%AE%E9%A2%84%E5%A4%84%E7%90%86font"><span class="toc-number">4.</span> <span class="toc-text">4. 数据预处理</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-5-alpha%E5%A4%9A%E6%A0%B7%E6%80%A7font"><span class="toc-number">5.</span> <span class="toc-text">5. alpha 多样性</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-6-%CE%B2%E5%A4%9A%E6%A0%B7%E6%80%A7font"><span class="toc-number">6.</span> <span class="toc-text">6. β 多样性</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-7-trans_abund-classfont"><span class="toc-number">7.</span> <span class="toc-text">7. trans_abund class</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-8-trans_venn-classfont"><span class="toc-number">8.</span> <span class="toc-text">8. trans_venn class</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-9-trans_alpha-classfont"><span class="toc-number">9.</span> <span class="toc-text">9. trans_alpha class</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-10-trans_beta-classfont"><span class="toc-number">10.</span> <span class="toc-text">10. trans_beta class</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-11-trans_diff-classfont"><span class="toc-number">11.</span> <span class="toc-text">11. trans_diff class</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-12-trans_env-classfont"><span class="toc-number">12.</span> <span class="toc-text">12. trans_env class</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-13-trans_nullmodel-classfont"><span class="toc-number">13.</span> <span class="toc-text">13. trans_nullmodel class</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-14-trans_network-classfont"><span class="toc-number">14.</span> <span class="toc-text">14. trans_network class</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#font-colorff9800-correlation-based-networkfont"><span class="toc-number">14.1.</span> <span class="toc-text">correlation-based network</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#font-colorff9800-%E6%9E%84%E5%BB%BA%E7%BD%91%E7%BB%9Cfont"><span class="toc-number">14.2.</span> <span class="toc-text">构建网络</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-15-trans_func-classfont"><span class="toc-number">15.</span> <span class="toc-text">15. trans_func class</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-16-%E7%9F%A5%E8%AF%86%E7%82%B9font"><span class="toc-number">16.</span> <span class="toc-text">16. 知识点</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#font-colorff9800-%E7%A1%AE%E5%AE%9A%E6%80%A7%E8%BF%87%E7%A8%8B%E5%92%8C%E9%9A%8F%E6%9C%BA%E8%BF%87%E7%A8%8Bfont"><span class="toc-number">16.1.</span> <span class="toc-text">确定性过程和随机过程</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#font-colorff0000-17-%E5%8F%82%E8%80%83font"><span class="toc-number">17.</span> <span class="toc-text">17. 参考</span></a></li></ol></div><div class="related panel pjax" data-title="Related"><ul><li><a href="/post/19824.html" rel="bookmark" title="生物信息学1：VMware虚拟机及Bio-linux安装与配置">生物信息学1：VMware虚拟机及Bio-linux安装与配置</a></li><li><a href="/post/9.html" rel="bookmark" title="生物信息学2：VirtualBox虚拟机及Bio-Linux安装">生物信息学2：VirtualBox虚拟机及Bio-Linux安装</a></li><li><a href="/post/10877.html" rel="bookmark" title="生物信息学3：微生物基因组学常用软件安装">生物信息学3：微生物基因组学常用软件安装</a></li><li><a href="/post/30650.html" rel="bookmark" title="根据基因组预测表型 —— traitar的安装与使用">根据基因组预测表型 —— traitar的安装与使用</a></li><li><a href="/post/44606.html" rel="bookmark" title="kSNP3寻找SNPs并构建进化树">kSNP3寻找SNPs并构建进化树</a></li><li><a href="/post/43504.html" rel="bookmark" title="用wget批量下载含有链接的文件/目录">用wget批量下载含有链接的文件/目录</a></li><li><a href="/post/94f2.html" rel="bookmark" title="为PubMed添加功能">为PubMed添加功能</a></li><li><a href="/post/4e1.html" rel="bookmark" title="OrthoFinder2—同源蛋白家族聚类">OrthoFinder2—同源蛋白家族聚类</a></li><li><a href="/post/848f.html" rel="bookmark" title="PGCGAP中文说明">PGCGAP中文说明</a></li><li><a href="/post/d163.html" rel="bookmark" title="Bioconda贡献指南">Bioconda贡献指南</a></li><li><a href="/post/f6c9.html" rel="bookmark" title="Linux和基因组测序技术初识">Linux和基因组测序技术初识</a></li><li><a href="/post/5908.html" rel="bookmark" title="BtToxin_Digger--A high-throughput Bacillus thuringiensis toxin mining pipeline">BtToxin_Digger--A high-throughput Bacillus thuringiensis toxin mining pipeline</a></li><li><a href="/post/ab1b.html" rel="bookmark" title="宏基因组分析流程及代码">宏基因组分析流程及代码</a></li><li class="active"><a href="/post/4cf4.html" rel="bookmark" title="Use microeco分析扩增子数据">Use microeco分析扩增子数据</a></li><li><a href="/post/1755.html" rel="bookmark" title="扩增子分析--计算随机过程和决定性过程比例">扩增子分析--计算随机过程和决定性过程比例</a></li><li><a href="/post/e7e9.html" rel="bookmark" title="根据assession number批量从NCB下载数据">根据assession number批量从NCB下载数据</a></li><li><a href="/post/e922.html" rel="bookmark" title="Swissprot数据库的本地化与序列比对并与其他数据库快速mapping">Swissprot数据库的本地化与序列比对并与其他数据库快速mapping</a></li><li><a href="/post/412a.html" rel="bookmark" title="构建样本vs基因矩阵">构建样本vs基因矩阵</a></li><li><a href="/post/9052.html" rel="bookmark" title="CAZy碳水化合物活性酶预测">CAZy碳水化合物活性酶预测</a></li><li><a href="/post/5324.html" rel="bookmark" title="原核生物基因岛预测">原核生物基因岛预测</a></li><li><a href="/post/d9f9.html" rel="bookmark" title="按照Contig切割GenBank文件">按照Contig切割GenBank文件</a></li><li><a href="/post/3a23.html" rel="bookmark" title="从GenBank文件中提取Features">从GenBank文件中提取Features</a></li><li><a href="/post/fb68.html" rel="bookmark" title="使用EffectiveT3预测微生物中的III型分泌系统效应蛋白">使用EffectiveT3预测微生物中的III型分泌系统效应蛋白</a></li><li><a href="/post/c886.html" rel="bookmark" title="SignalP+TMHMM预测微生物分泌蛋白">SignalP+TMHMM预测微生物分泌蛋白</a></li><li><a href="/post/6a93.html" rel="bookmark" title="在FASTA文件中搜索完全匹配的短序列">在FASTA文件中搜索完全匹配的短序列</a></li><li><a href="/post/ea71.html" rel="bookmark" title="在Linux服务器中安装网页版Rstudio">在Linux服务器中安装网页版Rstudio</a></li><li><a href="/post/a713.html" rel="bookmark" title="R语言安装依赖包错误集锦">R语言安装依赖包错误集锦</a></li><li><a href="/post/d444.html" rel="bookmark" title="NCBI上传基因簇之tbl2asn的使用">NCBI上传基因簇之tbl2asn的使用</a></li><li><a href="/post/18ea.html" rel="bookmark" title="利用NCycDB数据库从宏基因组中预测氮循环基因">利用NCycDB数据库从宏基因组中预测氮循环基因</a></li><li><a href="/post/36cc.html" rel="bookmark" title="R语言绘制分组条形图">R语言绘制分组条形图</a></li><li><a href="/post/1551.html" rel="bookmark" title="宏病毒组分析流程1-VirSorter2">宏病毒组分析流程1-VirSorter2</a></li><li><a href="/post/8fb3.html" rel="bookmark" title="利用GTDB-TK对细菌和古菌基因组进行物种分类">利用GTDB-TK对细菌和古菌基因组进行物种分类</a></li><li><a href="/post/85d7.html" rel="bookmark" title="计算蛋白质等电点并绘制全局pI图">计算蛋白质等电点并绘制全局pI图</a></li><li><a href="/post/92eb.html" rel="bookmark" title="使用DeepARG预测抗生素抗性基因ARGs">使用DeepARG预测抗生素抗性基因ARGs</a></li><li><a href="/post/74ad.html" rel="bookmark" title="Nanopore基因组组装">Nanopore基因组组装</a></li><li><a href="/post/2581.html" rel="bookmark" title="使用eggNOG-mapper注释基因组">使用eggNOG-mapper注释基因组</a></li><li><a href="/post/d862.html" rel="bookmark" title="PGCGAP - the Prokaryotic Genomics and Comparative Genomics Analysis Pipeline v1.0.33">PGCGAP - the Prokaryotic Genomics and Comparative Genomics Analysis Pipeline v1.0.33</a></li><li><a href="/post/e6ae.html" rel="bookmark" title="利用PGCGAP根据ids提取序列信息">利用PGCGAP根据ids提取序列信息</a></li><li><a href="/post/213.html" rel="bookmark" title="多种方法批量下载NCBI基因组">多种方法批量下载NCBI基因组</a></li><li><a href="/post/33b.html" rel="bookmark" title="代谢组相关软件的安装及使用">代谢组相关软件的安装及使用</a></li><li><a href="/post/377e.html" rel="bookmark" title="使用xcms3处理和分析LC-MS数据">使用xcms3处理和分析LC-MS数据</a></li><li><a href="/post/df57.html" rel="bookmark" title="用metid构建代谢组数据库">用metid构建代谢组数据库</a></li><li><a href="/post/0.html" rel="bookmark" title="基于TidyMass的非靶向代谢组学分析">基于TidyMass的非靶向代谢组学分析</a></li><li><a href="/post/29bf.html" rel="bookmark" title="批量下载某研究方向重要文献">批量下载某研究方向重要文献</a></li><li><a href="/post/c617.html" rel="bookmark" title="16S扩增子测序及宏基因组测序">16S扩增子测序及宏基因组测序</a></li><li><a href="/post/1177.html" rel="bookmark" title="用MaAsLin2包做微生物组多变量线性模型关联分析">用MaAsLin2包做微生物组多变量线性模型关联分析</a></li><li><a href="/post/7449.html" rel="bookmark" title="NCBI上传基因簇之table2asn的使用">NCBI上传基因簇之table2asn的使用</a></li></ul></div><div class="overview panel" data-title="Overview"><div class="author" itemprop="author" itemscope itemtype="http://schema.org/Person"><img class="image" itemprop="image" alt="Hualin Liu" data-src="/images/head.jpg"><p class="name" itemprop="name">Hualin Liu</p><div class="description" itemprop="description">分享微生物生物信息学分析方法，欢迎加入QQ群交流945751012，不接受群内广告！</div></div><nav class="state"><div class="item posts"><a href="/archives/"><span class="count">130</span> <span class="name">posts</span></a></div><div class="item categories"><a href="/categories/"><span class="count">12</span> <span class="name">categories</span></a></div><div class="item tags"><a href="/tags/"><span class="count">54</span> <span class="name">tags</span></a></div></nav><div class="social"><span class="exturl item github" data-url="aHR0cDovL2dpdGh1Yi5jb20vbGlhb2NoZW5sYW5ydW8=" title="http:&#x2F;&#x2F;github.com&#x2F;liaochenlanruo"><i class="ic i-github"></i></span> <span class="exturl item zhihu" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9zdWFuLWxhLW1pYW4tcGlhbi10YW5nLWNpdW0=" title="https:&#x2F;&#x2F;www.zhihu.com&#x2F;people&#x2F;suan-la-mian-pian-tang-cium"><i class="ic i-zhihu"></i></span> <span class="exturl item weibo" data-url="aHR0cHM6Ly93ZWliby5jb20vdS8yNzE1MjEwOTIz" title="https:&#x2F;&#x2F;weibo.com&#x2F;u&#x2F;2715210923"><i class="ic i-weibo"></i></span> <span class="exturl item about" data-url="aHR0cHM6Ly93d3cubGlhb2NoZW5sYW5ydW8uZnVuL2Fib3V0" title="https:&#x2F;&#x2F;www.liaochenlanruo.fun&#x2F;about"><i class="ic i-address-card"></i></span> <span class="exturl item email" data-url="bWFpbHRvOmxpYW9jaGVubGFucnVvQHdlYm1haWwuaHphdS5lZHUuY24=" title="mailto:liaochenlanruo@webmail.hzau.edu.cn"><i class="ic i-envelope"></i></span> <span class="exturl item douban" data-url="aHR0cHM6Ly93d3cuZG91YmFuLmNvbS9wZW9wbGUvbGlhb2NoZW5sYW5ydW8vP19pPTczNDYxMjVRalo1QjZWLw==" title="https:&#x2F;&#x2F;www.douban.com&#x2F;people&#x2F;liaochenlanruo&#x2F;?_i&#x3D;7346125QjZ5B6V&#x2F;"><i class="ic i-douban"></i></span> <span class="exturl item google" data-url="aHR0cHM6Ly9zY2hvbGFyLmdvb2dsZS5jby5qcC9jaXRhdGlvbnM/dXNlcj1YYW9STk1RQUFBQUomaGw9amE=" title="https:&#x2F;&#x2F;scholar.google.co.jp&#x2F;citations?user&#x3D;XaoRNMQAAAAJ&amp;hl&#x3D;ja"><i class="ic i-google"></i></span></div><ul class="menu"><li class="item"><a href="/" rel="section"><i class="ic i-home"></i>Home</a></li><li class="item dropdown"><a href="javascript:void(0);"><i class="ic i-user"></i>About</a><ul class="submenu"><li class="item"><a href="/about/" rel="section"><i class="ic i-user"></i>About me</a></li><li class="item"><a href="/comment/" rel="section"><i class="ic i-envelope"></i>Comment</a></li></ul></li><li class="item dropdown"><a href="javascript:void(0);"><i class="ic i-feather"></i>Posts</a><ul class="submenu"><li class="item"><a href="/archives/" rel="section"><i class="ic i-list-alt"></i>Archives</a></li><li class="item"><a href="/categories/" rel="section"><i class="ic i-th"></i>Categories</a></li><li class="item"><a href="/tags/" rel="section"><i class="ic i-tags"></i>Tags</a></li></ul></li><li class="item dropdown"><a href="javascript:void(0);"><i class="ic i-list-ol"></i>List</a><ul class="submenu"><li class="item"><a href="/photos/" rel="section"><i class="ic i-person"></i>Photos</a></li><li class="item"><a href="/skip/gallery/" rel="section"><i class="ic i-cloud"></i>Gallery</a></li><li class="item"><a href="/skip/box/" rel="section"><i class="ic i-magic"></i>Box</a></li><li class="item"><span class="exturl" data-url="aHR0cHM6Ly9saWFvY2hlbmxhbnJ1by5mdW4vcmVmZXJlbmNlLw=="><i class="ic i-th"></i>cheatsheets</span></li></ul></li><li class="item"><a href="/donate/" rel="section"><i class="ic i-coffee"></i>Donate</a></li><li class="item"><a href="/friends/" rel="section"><i class="ic i-heart"></i>Friends</a></li><li class="item"><span class="exturl" data-url="aHR0cHM6Ly9saWFvY2hlbmxhbnJ1by5naXRodWIuaW8="><i class="ic i-external-link-alt"></i>中文版</span></li><li class="item"><span class="exturl" data-url="aHR0cHM6Ly90cmF2ZWxsaW5ncy5saW5r"><i class="ic i-forward"></i>Travelling</span></li></ul></div></div></div><ul id="quick"><li class="prev pjax"><a href="/post/ab1b.html" rel="prev" title="Previous Post"><i class="ic i-chevron-left"></i></a></li><li class="up"><i class="ic i-arrow-up"></i></li><li class="down"><i class="ic i-arrow-down"></i></li><li class="next pjax"><a href="/post/1755.html" rel="next" title="Next Post"><i class="ic i-chevron-right"></i></a></li><li class="percent"></li></ul></div></div><div class="dimmer"></div></div></main><footer id="footer"><div class="inner"><div class="widgets"></div><div class="status"><div class="copyright">&copy; 2018 – <span itemprop="copyrightYear">2024</span> <span class="with-love"><i class="ic i-sakura rotate"></i> </span><span class="author" itemprop="copyrightHolder">Hualin Liu @ ResearchGo</span></div><div class="count"><span class="post-meta-item-icon"><i class="ic i-chart-area"></i> </span><span title="Symbols count total">788k words</span> <span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="ic i-coffee"></i> </span><span title="Reading time total">11:57</span><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="ic i-info-circle"></i> </span><span style="padding-left:1px"><span id="busuanzi_container_site_pv">Total visits: <span id="busuanzi_value_site_pv" style="color:#f99"></span> times</span> <span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="ic i-user"></i> </span><span style="padding-left:1px"><span id="busuanzi_container_site_uv">Total visitors: <span id="busuanzi_value_site_uv" style="color:#f99"></span> people</span></span></span></div><div class="powered-by">Powered by <span class="exturl" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & Theme.<span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2FtZWhpbWUvaGV4by10aGVtZS1zaG9rYQ==">Shoka</span></div></div></div></footer></div><script data-config type="text/javascript">var LOCAL={path:"post/4cf4.html",favicon:{show:"（●´3｀●）Goooood",hide:"(´Д｀)Booooom"},search:{placeholder:"Search for Posts",empty:"We didn't find any results for the search: ${query}",stats:"${hits} results found in ${time} ms"},valine:!0,fancybox:!0,copyright:'Copied to clipboard successfully! <br> All articles in this blog are licensed under <i class="ic i-creative-commons"></i>BY-NC-SA.',ignores:[function(e){return e.includes("#")},function(e){return new RegExp(LOCAL.path+"$").test(e)}]}</script><script src="https://cdn.polyfill.io/v2/polyfill.js"></script><script src="//cdn.jsdelivr.net/combine/npm/pace-js@1.0.2/pace.min.js,npm/pjax@0.2.8/pjax.min.js,npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js,npm/animejs@3.2.0/lib/anime.min.js,npm/algoliasearch@4/dist/algoliasearch-lite.umd.js,npm/instantsearch.js@4/dist/instantsearch.production.min.js,npm/lozad@1/dist/lozad.min.js,npm/quicklink@2/dist/quicklink.umd.js"></script><script src="/js/app.js?v=0.2.5"></script><script data-pjax>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?d211830a796ceefb38a141fde14e4d5a";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script></body></html>